Esempio n. 1
0
        private void layDS_Phong()
        {
            //cbbPhong.DataSource = null;
            //cbbPhong.Items.Clear();
            //cbbPhong.Refresh();

            DataTable dt = pbbus.DANH_SACH_PHONG_BAN(cbbMaCN.Text);

            //DataRow first_row = dt.NewRow();
            //first_row[0] = "Tất cả";
            //dt.Rows.InsertAt(first_row, 0);

            cbbPhong.DataSource    = dt;
            cbbPhong.DisplayMember = "TENPB";
            cbbPhong.ValueMember   = "MAPB";

            if (dt.Rows.Count > 0)
            {
                cbbPhong.SelectedIndex = 0;
            }



            //strCmd = "SELECT * FROM PHONGBAN WHERE MACN='" + cbbMaCN.Text.Trim() + "'";

            //SqlDataAdapter adapter = new SqlDataAdapter();
            //try
            //{
            //    frmMain.conn.Open();
            //    adapter.SelectCommand = new SqlCommand(strCmd, frmMain.conn);
            //    adapter.SelectCommand.ExecuteReader();
            //    frmMain.conn.Close();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //}

            //DataSet ds = new DataSet();
            //adapter.Fill(ds);

            //dtResult = ds.Tables[0];

            //int iRows = dtResult.Rows.Count;
            //for (int i = 0; i < iRows; i++)
            //{
            //    try
            //    {
            //        cbbPhong.Items.Add(dtResult.Rows[i]["TenPB"].ToString());
            //        arrPhong.Add(dtResult.Rows[i]["MaPB"].ToString());
            //        //arrChucvu.Add(dtResult.Rows[i]["Chucvu"].ToString());
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show(ex.ToString());
            //    }
            //}

            //if (iRows > 0)
            //{
            //    cbbPhong.SelectedIndex = 0;
            //}
        }