private void buttonOK_Click(object sender, EventArgs e) { if (!checkBox1.Checked) { TAISAN fixTS = new TAISAN(); fixTS.MaTS = comboBoxMaTS.SelectedValue.ToString(); fixTS.MaLoaiTS = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString()); fixTS.MaPhong = bll.GetMaPhong(comboBoxPhong.SelectedValue.ToString()); fixTS.SoLuong = bll.GetMaxSoLuong(fixTS.MaTS); fixTS.ThongSoKyThuat = textBoxTSKT.Text; fixTS.GhiChu = textBoxGhiChu.Text; fixTS.TenTS = textBoxTenTS.Text; fixTS.TyLeHM = int.Parse(numericUpDownTyLeHM.Value.ToString()); fixTS.TyLeCL = int.Parse(numericUpDownTyLeCL.Value.ToString()); d.Invoke(fixTS); } else { if (numericUpDown1.Value == bll.GetMaxSoLuong(comboBoxMaTS.SelectedValue.ToString())) { TAISAN fixTS = new TAISAN(); fixTS.MaTS = comboBoxMaTS.SelectedValue.ToString(); fixTS.MaLoaiTS = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString()); fixTS.MaPhong = bll.GetMaPhong(comboBoxPhongMoi.SelectedValue.ToString()); fixTS.ThongSoKyThuat = textBoxTSKT.Text; fixTS.GhiChu = textBoxGhiChu.Text; fixTS.TenTS = textBoxTenTS.Text; fixTS.TyLeHM = int.Parse(numericUpDownTyLeHM.Value.ToString()); fixTS.TyLeCL = int.Parse(numericUpDownTyLeCL.Value.ToString()); fixTS.SoLuong = int.Parse(numericUpDown1.Value.ToString()); d.Invoke(fixTS); } else { TAISAN fixTS = new TAISAN(); fixTS.MaTS = comboBoxMaTS.SelectedValue.ToString(); fixTS.MaLoaiTS = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString()); fixTS.MaPhong = bll.GetMaPhong(comboBoxPhong.SelectedValue.ToString()); fixTS.ThongSoKyThuat = textBoxTSKT.Text; fixTS.GhiChu = textBoxGhiChu.Text; fixTS.TenTS = textBoxTenTS.Text; fixTS.TyLeHM = int.Parse(numericUpDownTyLeHM.Value.ToString()); fixTS.TyLeCL = int.Parse(numericUpDownTyLeCL.Value.ToString()); fixTS.SoLuong = bll.GetMaxSoLuong(comboBoxMaTS.SelectedValue.ToString()) - (int)numericUpDown1.Value; TAISAN newTS = new TAISAN(); newTS.MaLoaiTS = bll.GetMaLoaiTS(comboBoxTenLoaiTS.SelectedValue.ToString()); newTS.MaPhong = bll.GetMaPhong(comboBoxPhongMoi.SelectedValue.ToString()); newTS.ThongSoKyThuat = textBoxTSKT.Text; newTS.GhiChu = textBoxGhiChu.Text; newTS.TenTS = textBoxTenTS.Text; newTS.NgayGhiTang = DateTime.Today; newTS.TyLeHM = int.Parse(numericUpDownTyLeHM.Value.ToString()); newTS.TyLeCL = int.Parse(numericUpDownTyLeCL.Value.ToString()); newTS.SoLuong = (int)numericUpDown1.Value; newTS.SoLuongCTT = newTS.SoLuong; newTS.MaChungTuTang = "04-TSCĐ-" + RandomString(8); string MaLoaiTaiSan = ""; MaLoaiTaiSan = newTS.MaLoaiTS; string MaPhong = ""; MaPhong = newTS.MaPhong; newTS.MaTS = bll.getMaTaiSan(MaLoaiTaiSan, MaPhong); bll.AddTS(newTS); d.Invoke(fixTS); } } this.Close(); MessageBox.Show("Sửa tài sản thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }