Esempio n. 1
0
        private void btnXoa_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (comDonVi.Text != "" || comHangHoa.Text != "" || comKH.Text != "" || comKho.Text != "" || comNhom.Text != "" || comNPP.Text != "")
            {
                if (stateEvent == "HangHoa")
                {
                    SQL_tblHangHoa temp  = new SQL_tblHangHoa();
                    EC_tblHangHoa  value = new EC_tblHangHoa();
                    value.HHMa = con.GetValue("select HHMa from tblHangHoa where HHTen like N'" + comHangHoa.Text + "'", 0);

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Hàng Hóa',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }
                else if (stateEvent == "DonVi")
                {
                    SQL_tblDonVi temp  = new SQL_tblDonVi();
                    EC_tblDonVi  value = new EC_tblDonVi();
                    value.DVTen = comDonVi.Text;

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Đơn Vị',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }
                else if (stateEvent == "KhachHang")
                {
                    SQL_tblKhachHang temp  = new SQL_tblKhachHang();
                    EC_tblKhachHang  value = new EC_tblKhachHang();
                    value.KHTen = comKH.Text;

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Khách Hàng',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }
                else if (stateEvent == "NPP")
                {
                    SQL_NPP   temp  = new SQL_NPP();
                    EC_tblNPP value = new EC_tblNPP();
                    value.NPPTen = comNPP.Text;

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Nhà Phân Phối',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }
                else if (stateEvent == "Nhom")
                {
                    SQL_Nhom   temp  = new SQL_Nhom();
                    EC_tblNhom value = new EC_tblNhom();
                    value.NTen = comNhom.Text;

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Nhóm',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }
                else if (stateEvent == "Kho")
                {
                    SQL_Kho   temp  = new SQL_Kho();
                    EC_tblKho value = new EC_tblKho();
                    value.KTen = comKho.Text;

                    temp.XoaDuLieu(value);

                    DateTime currentTime = DateTime.Now;
                    con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Kho',N'Xóa','" +
                                          string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
                }

                XtraMessageBox.Show("Đã Xóa!", "Thông báo");
                Them_Load(sender, e);
            }
            else
            {
                MessageBox.Show("Chưa chọn", "Thông báo");
            }
        }