Ejemplo n.º 1
0
        static public void Add(PhieuGachNo item, List <PhieuGachNoChiTiet> items)
        {
            dbControl = new QlShop();
            using (TransactionScope scope = new TransactionScope())
            {
                item.CreateDate = DateTime.Now;
                item.LastUpdate = DateTime.Now;
                dbControl.PhieuGachNoes.Add(item);
                dbControl.PhieuGachNoChiTiets.AddRange(items);

                foreach (PhieuGachNoChiTiet iPhieus in items)
                {
                    DonHangController.GachNo(iPhieus.DonHangID);
                }
                KhachHangController.GachNo(item.KhachHangID, item.TienThu);
                //cap nhat so luong ton kho

                //foreach (DonHangChiTiet DonHangItem in items)
                //{
                //    SanPhamController.CapNhatTonKho(DonHangItem.SanPhamID, DonHangItem.SoLuong);
                //}
                ////cap nha cong no va tong tien hang
                //if (item.KhachHangID != null)
                //{
                //    KhachHangController.CapNhatCongNo_MuaHang(item.KhachHangID, item.ConNo, item.TongCong);
                //}
                dbControl.SaveChanges();
                scope.Complete();
            }
        }
Ejemplo n.º 2
0
        private void save()
        {
            PhieuGachNo iPhieuGachNo = new PhieuGachNo();

            iPhieuGachNo.PhieuGachNoID = PhieuGachNoController.TaoMaPhieuGachNo("GN", 8);
            iPhieuGachNo.KhachHangID   = txtKhachHangID.Text;
            iPhieuGachNo.TenKhachHang  = txtTenKhachHang.Text;
            iPhieuGachNo.TienNoHienTai = calcEditConNo.Value;
            iPhieuGachNo.TienThu       = calcEditSoTienThu.Value;
            iPhieuGachNo.NguoiDungID   = txtNhanVien.Text;
            iPhieuGachNo.NgayGachNo    = dateEditNgayThu.DateTime;
            List <PhieuGachNoChiTiet> ListPhieu = new List <PhieuGachNoChiTiet>();

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (Convert.ToBoolean(gridView1.GetRowCellValue(i, "Chon")))
                {
                    PhieuGachNoChiTiet newitem = new PhieuGachNoChiTiet();
                    newitem.DonHangID     = gridView1.GetRowCellValue(i, "DonHangID").ToString();
                    newitem.PhieuGachNoID = iPhieuGachNo.PhieuGachNoID;
                    newitem.TienNo        = Convert.ToDecimal(gridView1.GetRowCellValue(i, "ConNo"));
                    ListPhieu.Add(newitem);
                }
            }
            PhieuGachNoController.Add(iPhieuGachNo, ListPhieu);
            //fanit82 modify for v3
            //đưa tiền gạch nợ vào quỹ tiền mặt
            QuyTienMatController.NhapQuyTienMat(iPhieuGachNo.PhieuGachNoID, iPhieuGachNo.NgayGachNo, iPhieuGachNo.TienThu, "GN", "Khách trả tiền nợ");
            txtSoPhieu.Text = iPhieuGachNo.PhieuGachNoID;
            strTrangThai    = "view";
            DieuKhienTrangThai();
        }