Example #1
0
 private void txtMaSach_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (!Object.ReferenceEquals(null, sachCtrl.GetSach(txtMaSach.Text.Trim())))
         {
             Sach s = new Sach();
             s = sachCtrl.GetSach(txtMaSach.Text.Trim());
             txtTenSach.DataBindings.Clear();
             txtTenSach.DataBindings.Add("Text", s, "TenSach");
             txtGiaBan.DataBindings.Clear();
             txtGiaBan.DataBindings.Add("Text", s, "GiaBan");
             txtGiaNhap.DataBindings.Clear();
             txtGiaNhap.DataBindings.Add("Text", s, "GiaNhap");
             txtGiamGia.DataBindings.Clear();
             txtGiamGia.DataBindings.Add("Text", s, "GiamGia");
             cbbLoaiSach.SelectedIndex = cbbLoaiSach.FindStringExact(tlSer.GetData(s.MaTL).TenTL);
             cbbNXB.SelectedIndex      = cbbNXB.FindStringExact(nxbSer.GetData(s.MaNXB).TenNXB);
             cbbTG.SelectedIndex       = cbbTG.FindStringExact(tgSer.GetData(s.MaTG).TenTG);
         }
         else
         {
             txtTenSach.Text           = "";
             txtGiaBan.Text            = "";
             txtGiaNhap.Text           = "";
             txtGiamGia.Text           = "";
             txtSLNhap.Text            = "";
             cbbLoaiSach.SelectedIndex = 0;
             cbbNXB.SelectedIndex      = 0;
             cbbTG.SelectedIndex       = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.ToString());
     }
 }
Example #2
0
 private void dtgvSach_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     foreach (DataGridViewRow row in dtgvSach.SelectedRows)
     {
         cbbLoaiSach.SelectedIndex = cbbLoaiSach.FindStringExact(tlSer.GetData(row.Cells["MaTL"].Value.ToString()).TenTL);
     }
     foreach (DataGridViewRow row in dtgvSach.SelectedRows)
     {
         cbbTG.SelectedIndex = cbbTG.FindStringExact(tgSer.GetData(row.Cells["MaTG"].Value.ToString()).TenTG);
     }
     foreach (DataGridViewRow row in dtgvSach.SelectedRows)
     {
         cbbNXB.SelectedIndex = cbbNXB.FindStringExact(nxbSer.GetData(row.Cells["MaNXB"].Value.ToString()).TenNXB);
     }
 }