public void XoaPhieuNhap(string mapn)
        {
            PHIEU_NHAP pn = data.PHIEU_NHAPs.Where(t => t.MaPN == mapn).FirstOrDefault();

            data.PHIEU_NHAPs.DeleteOnSubmit(pn);
            data.SubmitChanges();
        }
Beispiel #2
0
 private void btnThemPhieuNhap_Click(object sender, EventArgs e)
 {
     if (cboNhanVien.SelectedValue == null)
     {
         MessageBox.Show("Bạn chưa chọn người lập phiếu");
         return;
     }
     if (cboKho.SelectedValue == null)
     {
         MessageBox.Show("Bạn chưa chọn kho");
         return;
     }
     else
     {
         PHIEU_NHAP p = new PHIEU_NHAP();
         p.MAPN     = txtMaSoPhieu.Text.Trim();
         p.MANV     = cboNhanVien.SelectedValue.ToString();
         p.NGAYNHAP = datePhieuNhap.Value;
         p.NOIDUNG  = txtDienGiai.Text;
         p.MAKHO    = cboKho.SelectedValue.ToString();
         if (pn.ThemPhieuNhap(p))
         {
             btnThemSP.Enabled        = true;
             cboKho.Enabled           = false;
             cboNhanVien.Enabled      = false;
             btnThemPhieuNhap.Enabled = false;
             cboSP.Enabled            = true;
             MessageBox.Show("Bạn đã thêm phiếu " + p.MAPN);
         }
         else
         {
             MessageBox.Show("Thêm thất bại");
         }
     }
 }
        public void SuaPhieuNhap(string mapn, string mancc, string manv, DateTime thGian, int giamGia, long tongTien)
        {
            PHIEU_NHAP pn = data.PHIEU_NHAPs.Where(t => t.MaPN == mapn).FirstOrDefault();

            pn.MaNV     = manv;
            pn.MaNCC    = mancc;
            pn.ThoiGian = thGian;
            pn.GiamGia  = giamGia;
            pn.TongTien = tongTien;
            data.SubmitChanges();
        }
        public void ThemPhieuNhap(string mapn, string mancc, string manv, DateTime thGian, int giamGia)
        {
            PHIEU_NHAP pn = new PHIEU_NHAP();

            pn.MaPN     = mapn;
            pn.MaNV     = manv;
            pn.MaNCC    = mancc;
            pn.ThoiGian = thGian;
            pn.GiamGia  = giamGia;
            pn.TongTien = 0;
            data.PHIEU_NHAPs.InsertOnSubmit(pn);
            data.SubmitChanges();
        }
Beispiel #5
0
        private void btn_Luu_Click(object sender, EventArgs e)
        {
            if (IsValidate())
            {
                PHIEU_NHAP pn = new PHIEU_NHAP();
                pn.ID_NCC        = int.Parse(lkup_NhaCungCap.EditValue.ToString());
                pn.So_Phieu_Nhap = txt_SoPhieuNhap.Text;
                pn.Ngay_Lap      = dt_NgayLap.DateTime;
                pn.Tong_Tien     = decimal.Parse(txt_ThanhTien.Text);
                pn.VAT           = (double?)spin_VAT.Value;
                pn.Giam_Gia      = (double?)spin_GiamGia.Value;
                // Thêm phiếu nhập
                int idPhieuNhap;
                if (IsUpdate == false)
                {
                    idPhieuNhap = _nhapHangBLL.ThemPhieuNhapHang(pn);
                }
                else
                {
                    pn.ID_Phieu_Nhap = _nhapHangBLL.LayIDPhieuNhapTheoSoPhieuNhap(pn.So_Phieu_Nhap);
                    idPhieuNhap      = pn.ID_Phieu_Nhap;
                    _nhapHangBLL.CapNhatPhieuNhap(pn);
                }

                List <CHI_TIET_PHIEU_NHAP> dsChiTietPN = new List <CHI_TIET_PHIEU_NHAP>();
                if (gridView_CTPN.RowCount > 0)
                {
                    for (int i = 0; i < gridView_CTPN.RowCount; i++)
                    {
                        CHI_TIET_PHIEU_NHAP ct = new CHI_TIET_PHIEU_NHAP();
                        ct.ID_Phieu_Nhap  = idPhieuNhap;
                        ct.ID_Nguyen_Lieu = int.Parse(gridView_CTPN.GetRowCellValue(i, "ID_Nguyen_Lieu").ToString());
                        ct.So_Luong       = int.Parse(gridView_CTPN.GetRowCellValue(i, "So_Luong").ToString());
                        ct.Don_Gia        = int.Parse(gridView_CTPN.GetRowCellValue(i, "Don_Gia").ToString());
                        ct.Thanh_Tien     = int.Parse(gridView_CTPN.GetRowCellValue(i, "Thanh_Tien").ToString());

                        dsChiTietPN.Add(ct);
                    }
                }
                _nhapHangBLL.ThemChiTietPhieuNhap(dsChiTietPN, idPhieuNhap);
                Utils.Notification.Success("Thêm mới phiếu nhập hàng thành công!");

                Frm_Nhap_Hang_Load(sender, e); // Load lại tất cả dư liệu thay đổi

                ClearAll();                    // Refresh data control
            }
        }
 public frmPhieuNhap(PHIEU_NHAP phNhap)
 {
     InitializeComponent();
     this.phieuNhap = phNhap;
 }
        public PHIEU_NHAP TimPhieuNhapTheoMaPN(string ma)
        {
            PHIEU_NHAP pn = data.PHIEU_NHAPs.Where(t => t.MaPN == ma).FirstOrDefault();

            return(pn);
        }
        public bool KiemTraKhoaChinh(string mapn)
        {
            PHIEU_NHAP pn = data.PHIEU_NHAPs.Where(t => t.MaPN == mapn).FirstOrDefault();

            return(pn != null);
        }