public ActionResult LapPhieu(FormCollection collection)
        {
            PhieuChuyenKho PCK     = new PhieuChuyenKho();
            List <PhieuCK> listPCK = LayPhieu();

            PCK.SoLuongChuyen = TongSoLuong();
            PCK.FromKho       = int.Parse(User.TenCuaHang());
            PCK.NgayTao       = DateTime.Now;
            PCK.ToKho         = int.Parse(collection["KhoHangId"]);
            PCK.TrangThaiId   = 0;
            db.PhieuChuyenKhos.Add(PCK);
            foreach (var item in listPCK)
            {
                CTPhieuChuyenKho CTPCK = new CTPhieuChuyenKho();
                CTPCK.PhieuChuyenKhoId = PCK.PhieuChuyenKhoId;
                CTPCK.SanPhamId        = item.pSanPhamId;
                CTPCK.SoLuongChuyen    = item.pSoLuongChuyen;
                db.CTPhieuChuyenKhos.Add(CTPCK);

                var get = db.SanPhams.SingleOrDefault(n => n.SanPhamId == item.pSanPhamId);
                get.tempSoLuong     = (get.SoLuong - item.pSoLuongChuyen);
                db.Entry(get).State = EntityState.Modified;
            }
            db.SaveChanges();
            InformMailAsync();

            Session["PhieuCK"] = null;
            return(RedirectToAction("PhieuChuyenHang"));
        }
Beispiel #2
0
        private void BtnLuu_Click(object sender, EventArgs e)
        {
            if (gvPhieuChuyenKho.Rows.Count <= 1)
            {
                MessageBox.Show("Dữ liệu trống, không thể lưu");
                return;
            }
            if (lkueNguoiChuyen.EditValue == null)
            {
                MessageBox.Show("Vui lòng chọn Người nhận");
                return;
            }
            if (lkueKhoNhan.EditValue == null)
            {
                MessageBox.Show("Chưa chọn Kho Nhận");
                return;
            }
            PhieuChuyenKho pck = new PhieuChuyenKho();

            pck.MaPhieuChuyen  = txtMaPhieu.Text;
            pck.KhoXuatHang    = lkueKhoXuat.EditValue.ToString();
            pck.KhoNhanHang    = lkueKhoNhan.EditValue.ToString();
            pck.NVChuyen       = lkueNguoiChuyen.EditValue.ToString();
            pck.NVNhan         = lkueNguoiNhan.EditValue.ToString();
            pck.NgayLap        = DateTime.Parse(deNgayLap.EditValue.ToString());
            pck.GhiChu         = rtxtGhiChu.Text;
            pck.PhieuChuyenTay = txtPhieuChuyenTay.Text;

            List <CT_PhieuChuyenKho> lstCT_PCK = new List <CT_PhieuChuyenKho>();

            for (int i = 0; i < gvPhieuChuyenKho.Rows.Count - 1; i++)
            {
                CT_PhieuChuyenKho ct_pck = new CT_PhieuChuyenKho();
                ct_pck.MaPhieuChuyen = pck.MaPhieuChuyen;
                ct_pck.MaHang        = gvPhieuChuyenKho.Rows[i].Cells["colMaHang"].Value.ToString();
                ct_pck.SoLuong       = int.Parse(gvPhieuChuyenKho.Rows[i].Cells["colSoLuong"].Value.ToString());

                lstCT_PCK.Add(ct_pck);
            }
            nv_pck.ThemPhieuChuyenKho(pck);

            foreach (CT_PhieuChuyenKho ct in lstCT_PCK)
            {
                nv_ctpc.ThemCTPhieuChuyen(ct);
            }

            AddNhatKy("Thêm", TenChucNang);
            MessageBox.Show("Thêm thành công");

            if (cbInSauKhiLuu.Checked)
            {
                //print preview
                AddNhatKy("In", TenChucNang);
                PrintPreview();
            }
        }
        public int ThemPhieuChuyenKho(PhieuChuyenKho pc)
        {
            string sql = "insert into PHIEUCHUYENKHO(MaPhieuChuyen,KhoXuatHang,KhoNhanHang,NVChuyen," +
                         "NVNhan,PhieuChuyenTay,GhiChu,NgayLap) " +
                         string.Format("values ('{0}','{1}','{2}','{3}',",
                                       pc.MaPhieuChuyen, pc.KhoXuatHang, pc.KhoNhanHang, pc.NVChuyen) +
                         string.Format("'{0}','{1}',N'{2}','{3}')",
                                       pc.NVNhan, pc.PhieuChuyenTay, pc.GhiChu, pc.NgayLap);

            return(Execute.InsertUpdateDelete(sql));
        }
Beispiel #4
0
 public int ThemPhieuChuyenKho(PhieuChuyenKho pc)
 {
     return(xl_pc.ThemPhieuChuyenKho(pc));
 }