private void simpleButton5_Click(object sender, EventArgs e) { string MaHang = txtMaHang.Text; string TenHang = txtTenHang.Text; string MaPhanLoaiHangHoa = gridlookupPhanLoaiHangHoa.EditValue.ToString(); string MaLoaiHangHoa = gridlookupLoaiHangHoa.EditValue.ToString(); string MaKho = gridlookupKho.EditValue.ToString(); string MaVach = txtMaVach.Text; string MaDonVi = gridlookupDonVi.EditValue.ToString(); string MaNhaCC = gridlookupNCC.EditValue.ToString(); string XuatXu = txtXuatXu.Text; int TonKhoToiThieu; int.TryParse(txtTonKhoToiThieu.Text, out TonKhoToiThieu); int TonKhoHienTai; int.TryParse(txtTonHienTai.Text, out TonKhoHienTai); double GiaMua; double.TryParse(txtGiaMua.Text, out GiaMua); double GiaBanLe; double.TryParse(txtGiaBanLe.Text, out GiaBanLe); double GiaBanSi; double.TryParse(txtGiaBanSi.Text, out GiaBanSi); bool ConQuanLy; if (checkBox1.Checked == true) { ConQuanLy = true; } else { ConQuanLy = false; } HangHoaBUS.Them(MaHang, TenHang, MaPhanLoaiHangHoa, MaLoaiHangHoa, MaKho, MaVach, MaDonVi, MaNhaCC, XuatXu, TonKhoToiThieu, TonKhoHienTai, GiaMua, GiaBanLe, GiaBanSi, ConQuanLy); }
private void gvDanhMucHangHoa_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { if (gvDanhMucHangHoa.FocusedRowHandle > -1) { try { HangHoaDTO itemDTO = new HangHoaDTO(); HangHoaBUS itemBUS = new HangHoaBUS(); itemDTO.MaHangHoa = gvDanhMucHangHoa.GetFocusedRowCellValue("MaHangHoa").ToString(); itemDTO.TenHangHoa = gvDanhMucHangHoa.GetFocusedRowCellValue("TenHangHoa").ToString(); itemDTO.IdHoatChatChinh = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdHoatChatChinh").ToString()); itemDTO.IdNhomHangHoa = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdNhomHangHoa").ToString()); itemDTO.IdLoaiHangHoa = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdLoaiHangHoa").ToString()); itemDTO.IdHangSanXuat = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdHangSanXuat").ToString()); itemDTO.IdNoiSanXuat = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdNoiSanXuat").ToString()); itemDTO.IdViTri = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdViTri").ToString()); itemDTO.SoDangKy = gvDanhMucHangHoa.GetFocusedRowCellValue("SoDangKy").ToString(); itemDTO.IdDonViTinh = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdDonViTinh").ToString()); itemDTO.GiaNhap = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("GiaNhap").ToString()); itemDTO.TyLeChietKhau = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("TyLeChietKhau").ToString()); itemDTO.VAT = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("VAT").ToString()); itemDTO.IdDonViQuyDoi1 = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdDonViQuyDoi1").ToString()); itemDTO.TyLeQuyDoi1 = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("TyLeQuyDoi1").ToString()); itemDTO.GiaQuyDoi1 = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("GiaQuyDoi1").ToString()); itemDTO.GiaDeXuat1 = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("GiaDeXuat1").ToString()); itemDTO.IdDonViQuyDoi2 = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("IdDonViQuyDoi2").ToString()); itemDTO.TyLeQuyDoi2 = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("TyLeQuyDoi2").ToString()); itemDTO.GiaQuyDoi2 = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("GiaQuyDoi2").ToString()); itemDTO.GiaDeXuat2 = double.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("GiaDeXuat2").ToString()); itemDTO.NhietDoBaoQuan = gvDanhMucHangHoa.GetFocusedRowCellValue("NhietDoBaoQuan").ToString(); itemDTO.AnhSangBaoQuan = gvDanhMucHangHoa.GetFocusedRowCellValue("AnhSangBaoQuan").ToString(); itemDTO.DoAmBaoQuan = gvDanhMucHangHoa.GetFocusedRowCellValue("DoAmBaoQuan").ToString(); itemDTO.QuanLyKho = bool.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("QuanLyKho").ToString()); itemDTO.Id = int.Parse(gvDanhMucHangHoa.GetFocusedRowCellValue("Id").ToString()); if (this.flagThem && gvDanhMucHangHoa.FocusedRowHandle == gvDanhMucHangHoa.RowCount - 2) { if (itemDTO.MaHangHoa.Length > 0) { DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn thêm mới?", "Thêm mới", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (hopThoai == DialogResult.Yes) { itemBUS.Them(itemDTO); this.flagThem = false; } } else { MessageBox.Show("Bạn chưa nhập mã!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn cập nhật?", "Cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (hopThoai == DialogResult.Yes) { itemBUS.Sua(itemDTO); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.LayDanhSachHangHoa(); } }