コード例 #1
0
ファイル: frmCongNo.cs プロジェクト: eouen12/DoAnTotNghiep
        void CapNhatHanTraNo()
        {
            CongNoBUS.CapNhatCongNo(new CONGNO
            {
                MACONGNO  = cn.MACONGNO,
                MAHD      = cn.MAHD,
                MAKH      = cn.MAKH,
                TONGTIEN  = cn.TONGTIEN,
                TIENCONNO = cn.TIENCONNO,
                NGAYTRA   = this.dateTimePickerNgayTra.Value.Date,
                NV_LAPCN  = cn.NV_LAPCN,
                NGAYLAP   = cn.NGAYLAP.Value.Date,
                TRANGTHAI = cn.TRANGTHAI
            });
            MessageBox.Show("Cập nhật hạn trả nợ thành công !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            LoadDSCN();
            Reset();
            string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã cập nhật hạn trả nợ của mã công nợ " + cn.MACONGNO;

            LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
            {
                NGAYTAO       = DateTime.Now.Date,
                NV_THAOTAC    = this.manv,
                VITRI_THAOTAC = this.vitrithaotac,
                GHICHU        = lsth
            });
        }
コード例 #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (this.txtMasp.Text == string.Empty || this.txtSoLuong.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa điền đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.txtMasp.Focus();
                return;
            }
            if (!SanPhamBUS.KiemTraMaSPTonTai(this.txtMasp.Text))
            {
                MessageBox.Show("Mã sản phẩm không tồn tại !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtMasp.Focus();
                return;
            }

            if (!KiemTraSLMasp(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)))
            {
                this.txtSoLuong.Focus();
                return;
            }

            if (!KiemTraMaspTonTaiTrongCTHD(this.txtMasp.Text))
            {
                CTHoaDonBanHangBUS.ThemCTHoaDon(new CTHOADONBANHANG
                {
                    MAHD      = hd.MAHD,
                    MASP      = this.txtMasp.Text,
                    SOLUONG   = Convert.ToInt32(this.txtSoLuong.Text.Trim()),
                    DONGIA    = TinhDonGia(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)),
                    DVT       = sp.Where(p => p.MASP == this.txtMasp.Text).FirstOrDefault().DVT,
                    TRANGTHAI = true
                });
                MessageBox.Show("Thêm sản phẩm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadDSCTHD(hd.MAHD);
                CapNhatSoLuongSanPham(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text), 0);
                hd.TONGTIEN = lstcthd.Sum(p => p.DONGIA);
                HoaDonBanHangBUS.CapNhatHoaDon(hd);
                if (CongNoBUS.LayDanhSachCongNo().Where(p => p.MAKH == this.lblMaKH.Text && p.MAHD == hd.MAHD && p.TRANGTHAI == true).FirstOrDefault() != null)
                {
                    CapNhatThongTienCongNo();
                }
                this.dangThayDoiCTHD = false;
                loadThongTinHD(hd.MAHD);
                Reset();
                string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã thêm sản phẩm " + this.txtMasp.Text + " vào chi tiết hóa đơn " + hd.MAHD;
                LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
                {
                    NGAYTAO       = DateTime.Now.Date,
                    NV_THAOTAC    = this.manv,
                    VITRI_THAOTAC = this.vitrithaotac,
                    GHICHU        = lsth
                });
            }
            else
            {
                MessageBox.Show("Mã sản phẩm đã tồn tại !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtMasp.Focus();
                return;
            }
        }
コード例 #3
0
ファイル: frmLapHoaDon.cs プロジェクト: eouen12/DoAnTotNghiep
        void TaoCongNo()
        {
            List <CONGNO> lstcongno = CongNoBUS.LayDanhSachCongNo();
            string        macn;

            if (lstcongno.Count == 0)
            {
                macn = "CN1";
            }
            else
            {
                macn = lstcongno.Select(p => p.MACONGNO).LastOrDefault();
                int somacn = Convert.ToInt32(macn.Remove(0, 2)) + 1;
                macn = "CN" + somacn;
                for (int i = 0; i < lstcongno.Count(); i++)
                {
                    if (macn == lstcongno[i].MACONGNO)
                    {
                        somacn = Convert.ToInt32(macn.Remove(0, 2)) + 1;
                        macn   = "CN" + somacn;
                    }
                }
            }
            CongNoBUS.ThemCongNo(new CONGNO
            {
                MACONGNO  = macn,
                MAHD      = mahd,
                MAKH      = makh,
                NV_LAPCN  = this.manv,
                NGAYLAP   = DateTime.Now.Date,
                TONGTIEN  = Convert.ToDecimal(this.lblTongTien.Text),
                TIENCONNO = Convert.ToDecimal(this.lblTongTien.Text) - Convert.ToDecimal(this.txtSoTienTraTrc.Text),
                NGAYTRA   = this.dateHanTra.Value.Date,
                TRANGTHAI = true
            });

            LichSuTraNoBUS.TaoLichSuTraNo(new LICHSUTRANO
            {
                MACONGNO        = macn,
                NGAYTRA_THEODOI = DateTime.Now.Date,
                TIENTRA_THEODOI = Convert.ToDecimal(this.txtSoTienTraTrc.Text),
                TRANGTHAI       = true,
            });

            string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã lập công nợ " + macn;

            LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
            {
                NGAYTAO       = DateTime.Now.Date,
                NV_THAOTAC    = this.manv,
                VITRI_THAOTAC = this.vitrithaotac,
                GHICHU        = lsth
            });
        }
コード例 #4
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (this.txtMasp.Text == string.Empty || this.txtSoLuong.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa chọn dòng sản phẩm muốn cập nhật !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!KiemTraSLMasp(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)))
            {
                this.txtSoLuong.Focus();
                return;
            }
            CTHOADONBANHANG ct = new CTHOADONBANHANG
            {
                MAHD    = hd.MAHD,
                MASP    = this.txtMasp.Text,
                SOLUONG = Convert.ToInt32(this.txtSoLuong.Text.Trim()),
                DONGIA  = TinhDonGia(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text)),
                DVT     = sp.Where(p => p.MASP == this.txtMasp.Text).FirstOrDefault().DVT
            };


            if (CTHoaDonBanHangBUS.SuaCTHoaDon(ct))
            {
                MessageBox.Show("Cập nhật thông tin thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadDSCTHD(hd.MAHD);
                CapNhatSoLuongSanPham(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text), 1);
                hd.TONGTIEN = lstcthd.Sum(p => p.DONGIA);
                HoaDonBanHangBUS.CapNhatHoaDon(hd);
                if (CongNoBUS.LayDanhSachCongNo().Where(p => p.MAKH == this.lblMaKH.Text && p.MAHD == hd.MAHD && p.TRANGTHAI == true).FirstOrDefault() != null)
                {
                    CapNhatThongTienCongNo();
                }
                this.dangThayDoiCTHD = false;
                loadThongTinHD(hd.MAHD);
                Reset();
                string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã cập nhật thông tin chi tiết hóa đơn " + hd.MAHD;
                LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
                {
                    NGAYTAO       = DateTime.Now.Date,
                    NV_THAOTAC    = this.manv,
                    VITRI_THAOTAC = this.vitrithaotac,
                    GHICHU        = lsth
                });
            }
            else
            {
                MessageBox.Show("Cập nhật thông tin thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        void CapNhatThongTienCongNo()
        {
            var cn = CongNoBUS.LayDanhSachCongNo().Where(p => p.MAKH == this.lblMaKH.Text && p.MAHD == hd.MAHD).FirstOrDefault();

            if (hd.TONGTIEN == 0)
            {
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = cn.MAKH,
                    MAHD      = cn.MAHD,
                    TONGTIEN  = cn.TONGTIEN,
                    TIENCONNO = 0M,
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = false
                });
                //CongNoBUS.XoaCongNo(cn.MACONGNO);
            }
            else
            {
                // cn tong tien 15 , con no 10
                // hd edit tong tien 10, cn tong tien 10
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = cn.MAKH,
                    MAHD      = cn.MAHD,
                    TONGTIEN  = Convert.ToDecimal(hd.TONGTIEN),
                    TIENCONNO = Convert.ToDecimal(hd.TONGTIEN) - cn.TONGTIEN + cn.TIENCONNO,
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = true
                });
            }
        }
コード例 #6
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (this.txtMasp.Text == string.Empty || this.txtSoLuong.Text == string.Empty)
     {
         MessageBox.Show("Bạn chưa chọn dòng sản phẩm muốn xóa !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (MessageBox.Show("Bạn có chắc chứ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         if (CTHoaDonBanHangBUS.XoaCTHoaDon(hd.MAHD, this.txtMasp.Text))
         {
             MessageBox.Show("Xóa thông tin thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             loadDSCTHD(hd.MAHD);
             CapNhatSoLuongSanPham(this.txtMasp.Text, Convert.ToInt32(this.txtSoLuong.Text), 2);
             hd.TONGTIEN = lstcthd.Sum(p => p.DONGIA);
             HoaDonBanHangBUS.CapNhatHoaDon(hd);
             if (CongNoBUS.LayDanhSachCongNo().Where(p => p.MAKH == this.lblMaKH.Text && p.MAHD == hd.MAHD && p.TRANGTHAI == true).FirstOrDefault() != null)
             {
                 CapNhatThongTienCongNo();
             }
             this.dangThayDoiCTHD = false;
             loadThongTinHD(hd.MAHD);
             Reset();
             string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã xóa sản phẩm " + this.txtMasp.Text + " của chi tiết hóa đơn " + hd.MAHD;
             LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
             {
                 NGAYTAO       = DateTime.Now.Date,
                 NV_THAOTAC    = this.manv,
                 VITRI_THAOTAC = this.vitrithaotac,
                 GHICHU        = lsth
             });
         }
         else
         {
             MessageBox.Show("Xóa thông tin thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
コード例 #7
0
ファイル: frmCongNo.cs プロジェクト: eouen12/DoAnTotNghiep
        void LoadDSCN()
        {
            lstKhachhang = KhachHangBUS.LayDanhSachKhachHang();
            lstCongNo    = CongNoBUS.LayDanhSachCongNo().Where(p => p.TRANGTHAI == true).ToList();
            var kq = from cn in lstCongNo
                     join kh in lstKhachhang
                     on cn.MAKH equals kh.MAKH
                     select new
            {
                cn.MACONGNO,
                cn.MAKH,
                cn.MAHD,
                kh.TENKH,
                cn.TONGTIEN,
                cn.TIENCONNO,
                cn.NGAYTRA,
                cn.NV_LAPCN,
                cn.NGAYLAP
            };

            this.dgvCongNo.DataSource          = kq.ToList();
            this.dgvCongNo.AutoGenerateColumns = false;
        }
コード例 #8
0
ファイル: frmTrangChu.cs プロジェクト: eouen12/DoAnTotNghiep
        void LoadDSCNTheoThang(DateTime dt)
        {
            lstKhachhang = KhachHangBUS.LayDanhSachKhachHang();
            lstCongNo    = CongNoBUS.LayDanhSachCongNo().Where(p => p.TRANGTHAI == true).ToList();
            var kq = from cn in lstCongNo
                     join kh in lstKhachhang
                     on cn.MAKH equals kh.MAKH
                     where cn.NGAYTRA.Value.Month == dt.Month &&
                     cn.NGAYTRA.Value.Year == dt.Year
                     select new
            {
                cn.MACONGNO,
                cn.MAKH,
                kh.TENKH,
                cn.TONGTIEN,
                cn.TIENCONNO,
                cn.NGAYTRA,
            };

            this.label1.Text                     = "Danh sách công nợ cần thu trong tháng " + dt.Date.Month;
            this.dgvDSCongNo.DataSource          = kq.ToList();
            this.dgvDSCongNo.AutoGenerateColumns = false;
            FormatDataGridView();
        }
コード例 #9
0
ファイル: frmCongNo.cs プロジェクト: eouen12/DoAnTotNghiep
        void CapNhatCongNo()
        {
            if (this.txtSoTienTraHomNay.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa nhập tiền trả nợ !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Convert.ToDecimal(this.txtSoTienTraHomNay.Text) > cn.TIENCONNO)
            {
                MessageBox.Show("Số tiền trả đang lớn hơn số tiền còn nợ trong hóa đơn !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtSoTienTraHomNay.Focus();
                return;
            }
            if (cn.TIENCONNO == Convert.ToDecimal(this.txtSoTienTraHomNay.Text))
            {
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = this.dgvCongNo.CurrentRow.Cells["MAKHCongNo"].Value.ToString(),
                    MAHD      = cn.MAHD,
                    TONGTIEN  = cn.TONGTIEN,
                    TIENCONNO = 0M,
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = false
                });
                //CongNoBUS.XoaCongNo(cn.MACONGNO);
            }
            else
            {
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = this.dgvCongNo.CurrentRow.Cells["MAKHCongNo"].Value.ToString(),
                    MAHD      = cn.MAHD,
                    TONGTIEN  = cn.TONGTIEN,
                    TIENCONNO = Convert.ToDecimal(cn.TIENCONNO) - Convert.ToDecimal(this.txtSoTienTraHomNay.Text),
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = true
                });
            }
            LichSuTraNoBUS.TaoLichSuTraNo(new LICHSUTRANO
            {
                MACONGNO        = cn.MACONGNO,
                NGAYTRA_THEODOI = DateTime.Now.Date,
                TIENTRA_THEODOI = Convert.ToDecimal(this.txtSoTienTraHomNay.Text),
                TRANGTHAI       = true,
            });
            MessageBox.Show("Thanh toán thành công !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            LoadDSCN();
            Reset();
            string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã cập nhật thông tin của mã công nợ " + cn.MACONGNO;

            LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
            {
                NGAYTAO       = DateTime.Now.Date,
                NV_THAOTAC    = this.manv,
                VITRI_THAOTAC = this.vitrithaotac,
                GHICHU        = lsth
            });
        }