สมัครสมาชิก ลงชื่อเข้าใช้
Discuz Thai หน้าแรก

โปรไฟล์ของ Ukita https://discuzthai.com/?24880 [บุ๊คมาร์ก] [คัดลอก] [แชร์] [RSS]

บล็อก

bkrentSearch

เข้าชม/อ่าน 629 ครั้ง2012-5-30 10:02

public partial class bkrentSearch : Form
    {
        public bkrentSearch()
        {
            InitializeComponent();
        }
        private SqlConnection con()
        {
            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Book;User Id=sa;Password=123;");
            return con;
        }
        SqlDataAdapter adapJoin;
        DataView dv;
        DataSet ds;
        private void bkrentSearch_Load(object sender, EventArgs e)
        {
            ds = new DataSet();
            adapJoin = new SqlDataAdapter("select * from Books inner join bkrent on books.bk_id = bkrent.bk_id where bkrent_status = 1", con());
            adapJoin.Fill(ds, "joinbook");
            dv = new DataView(ds.Tables["joinbook"]);
            dataGridView3.AutoGenerateColumns = false;
            dataGridView3.DataSource = dv;

            for (int i = 0; i < dataGridView3.Rows.Count; i++)
            {
                if (Convert.ToInt16(ds.Tables["joinbook"].Rows[i]["bkrent_status"]) == 1)
                {
                    dataGridView3.Rows[i].Cells[4].Value = "หนังสือยังไม่ถูกเช่า";
                }
                else dataGridView3.Rows[i].Cells[4].Value = "หนังสือถูกเช่าไป";
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                dv.RowFilter = "bkrent_id like '%" + txtSend.Text + "%'";

            }
            else if (radioButton2.Checked)
            {
                dv.RowFilter = "bk_name like '%" + txtSend.Text + "%'";
            }
            else dv.RowFilter = "";
        }
        int i = 0;

        private void dataGridView3_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            i = e.RowIndex;
            if (i >= 0 && i < dv.Count)
            {
                Rent.BkrentID = dv[i]["bkrent_id"].ToString();
                Rent.BkID = dv[i]["bk_id"].ToString();
                this.Close();
            }
        }
    }
}

ความคิดเห็น (0 ความคิดเห็น)

รายชื่อผู้กระทำผิด|Archiver|ดิสคัส ไทย Follow us: Become a fan on facebook. Follow us on Twitter.

GMT+7, 2024-5-5 08:54

Powered by Discuz! X3.4, Rev.66

Copyright © 2001-2021 Tencent Cloud. Licensed

ขึ้นไปด้านบน