Exemple #1
0
 //ham xoa
 public void XoaDuLieu(EC_tblKho et)
 {
     cn.ThucThiCauLenhSQL("DELETE from tblKho WHERE KTen=N'" + et.KTen + "'");
 }
Exemple #2
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");
            }
        }
Exemple #3
0
 //ham them du lieu
 public void ThemDuLieu(EC_tblKho et)
 {
     cn.ThucThiCauLenhSQL("INSERT INTO tblKho (KMa, KTen, KNguoiLienHe, KDiaChi, KDienThoai, KNguoiQuanLi, KDienGiai) VALUES " +
                          "(N'" + et.KMa + "',N'" + et.KTen + "',N'" + et.KNguoiLienHe + "',N'" + et.KDiaChi + "',N'" + et.KDienThoai + "',N'" + et.KNguoiQuanLi + "',N'" + et.KDienGiai + "')");
 }
Exemple #4
0
        private void ThemDL(string state)
        {
            if (state == "HangHoa")
            {
                SQL_tblHangHoa temp  = new SQL_tblHangHoa();
                EC_tblHangHoa  value = new EC_tblHangHoa();

                value.HHMa         = txtMa.Text;
                value.HHTen        = txtTen.Text;
                txtSoLuong.Text    = "0";
                value.HHGia        = txtGia.Text;
                value.HHTonHienTai = txtSoLuong.Text;
                try
                {
                    value.KMa   = con.GetValue("select KMa from tblKho where KTen like N'" + gridlookKho.Text + "'", 0);
                    value.NMa   = con.GetValue("select NMa from tblNhom where NTen like N'" + gridlookNhom.Text + "'", 0);
                    value.DVMa  = con.GetValue("select DVMa from tblDonVi where DVTen like N'" + gridlookDonVi.Text + "'", 0);
                    value.NPPMa = con.GetValue("select NPPMa from tblNPP where NPPTen like N'" + gridlookNPP.Text + "'", 0);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                }

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu hoặc Mã bị trùng");
                    return;
                }

                XtraMessageBox.Show("Đã Thêm!");
                DateTime currentTime = DateTime.Now;
                con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Hàng Hóa',N'Thêm','" +
                                      string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
            }
            else if (state == "DonVi")
            {
                SQL_tblDonVi temp  = new SQL_tblDonVi();
                EC_tblDonVi  value = new EC_tblDonVi();

                value.DVMa     = txtMa.Text;
                value.DVTen    = txtTen.Text;
                value.DVGhiChu = txtSoLuong.Text;

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                    return;
                }
                XtraMessageBox.Show("Đã thêm!");
                DateTime currentTime = DateTime.Now;
            }
            else if (state == "KhachHang")
            {
                SQL_tblKhachHang temp  = new SQL_tblKhachHang();
                EC_tblKhachHang  value = new EC_tblKhachHang();

                value.KHMa        = txtMa.Text;
                value.KHTen       = txtTen.Text;
                value.KHDiaChi    = txtSoLuong.Text;
                value.KHDienThoai = txtGia.Text;
                value.KHMaSoThue  = txtGhiChu.Text;

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                    return;
                }

                XtraMessageBox.Show("Đã thêm");

                DateTime currentTime = DateTime.Now;
                con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Khách Hàng',N'Thêm','" +
                                      string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
            }
            else if (state == "Kho")
            {
                SQL_Kho   temp  = new SQL_Kho();
                EC_tblKho value = new EC_tblKho();

                value.KMa          = txtMa.Text;
                value.KTen         = txtTen.Text;
                value.KNguoiLienHe = value.KNguoiQuanLi = txtSoLuong.Text;
                value.KDiaChi      = txtGia.Text;

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                    return;
                }
                XtraMessageBox.Show("Đã thêm!");

                DateTime currentTime = DateTime.Now;
                con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Kho',N'Thêm','" +
                                      string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
            }
            else if (state == "Nhom")
            {
                SQL_Nhom   temp  = new SQL_Nhom();
                EC_tblNhom value = new EC_tblNhom();

                value.NMa     = txtMa.Text;
                value.NTen    = txtTen.Text;
                value.NGhiChu = txtSoLuong.Text;
                try
                {
                    value.KMa = con.GetValue("select KMa from tblKho where KTen like N'" + gridlookKho.Text + "'", 0);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                }

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu");

                    return;
                }

                XtraMessageBox.Show("Đã thêm!");

                DateTime currentTime = DateTime.Now;
                con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Nhóm',N'Thêm','" +
                                      string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
            }
            else if (state == "NPP")
            {
                SQL_NPP   temp  = new SQL_NPP();
                EC_tblNPP value = new EC_tblNPP();

                value.NPPMa       = txtMa.Text;
                value.NPPTen      = txtTen.Text;
                value.NPPDiaChi   = txtSoLuong.Text;
                value.NPPMaSoThue = txtGhiChu.Text;
                value.DienThoai   = txtGia.Text;

                try
                {
                    temp.ThemDuLieu(value);
                }
                catch
                {
                    XtraMessageBox.Show("Nhập thiếu!");
                    return;
                }

                XtraMessageBox.Show("Đã thêm!");

                DateTime currentTime = DateTime.Now;
                con.ThucThiCauLenhSQL("insert into tblNhatKi (NKTen,NKTacVu,NKNgay,NKUser) values (N'Nhà Phân Phối',N'Thêm','" +
                                      string.Format("{0:yyyy/MM/dd HH:mm:ss}", currentTime) + "',N'" + lbNameUser + "')");
            }
        }