private void FormHDBanHang_Them_Load(object sender, EventArgs e) { try { txt_MaHD.Clear(); txt_Ngay.Clear(); txt_MaHD.Focus(); lb_Tien.Text = "0"; //xử lí combobox khách hàng ds_KH = KH.GetDaTa(); dt_KH = ds_KH.Tables[0]; cbBox_MaKH.DataSource = dt_KH.Copy(); cbBox_MaKH.DisplayMember = "Ten_KH"; cbBox_MaKH.ValueMember = "Ma_KH"; //xử lí combobox nhân viên ds_NV = NV.LayNV(); dt_NV = ds_NV.Tables[0]; cbBox_MaNV.DataSource = dt_NV.Copy(); cbBox_MaNV.DisplayMember = "Ten_NV"; cbBox_MaNV.ValueMember = "Ma_NV"; DateTime thoigian = DateTime.Now; txt_Ngay.Text = thoigian.ToString(); } catch { MessageBox.Show("Lỗi nhé!!!!"); } }
private void FormHDBanHang_Sua_Load(object sender, EventArgs e) { try { txt_MaHD.Clear(); txt_Ngay.Clear(); txt_MaHD.Focus(); lb_Tien.ResetText(); //xử lí textbox ds_HD = HD.HoaDonTheoMaHD(BienCucBo.Ma_HDBH); dt_HD = ds_HD.Tables[0]; txt_MaHD.DataBindings.Add("Text", dt_HD, "Ma_HDBH"); txt_Ngay.DataBindings.Add("Text", dt_HD, "NgayXuatHD"); lb_Tien.DataBindings.Add("Text", dt_HD, "TongTien"); //xử lí combobox khách hàng ds_KH = KH.GetDaTa(); dt_KH = ds_KH.Tables[0]; cbBox_MaKH.DataSource = dt_KH.Copy(); cbBox_MaKH.DisplayMember = "Ten_KH"; cbBox_MaKH.ValueMember = "Ma_KH"; string MaKH = dt_HD.Rows[0][2].ToString(); cbBox_MaKH.SelectedValue = MaKH; //xử lí combobox nhân viên ds_NV = NV.LayNV(); dt_NV = ds_NV.Tables[0]; cbBox_MaNV.DataSource = dt_NV.Copy(); cbBox_MaNV.DisplayMember = "Ten_NV"; cbBox_MaNV.ValueMember = "Ma_NV"; string MaNV = dt_HD.Rows[0][1].ToString(); cbBox_MaNV.SelectedValue = MaNV; } catch { MessageBox.Show("Lỗi nhé!!!!"); } }