示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ChiTietBaoCaoTonKho chiTietBaoCaoTonKho = db.ChiTietBaoCaoTonKhoes.Find(id);

            db.ChiTietBaoCaoTonKhoes.Remove(chiTietBaoCaoTonKho);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "MaBaoCaoTonKho,MaHangHoa,SoLuongTonDau,SoLuongNhap,SoLuongXuat,SoLuongTonCuoi,TinhTrangHangHoa")] ChiTietBaoCaoTonKho chiTietBaoCaoTonKho)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chiTietBaoCaoTonKho).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaBaoCaoTonKho = new SelectList(db.BaoCaoTonKhoes, "MaBaoCaoTonKho", "MaBaoCaoTonKho", chiTietBaoCaoTonKho.MaBaoCaoTonKho);
     ViewBag.MaHangHoa      = new SelectList(db.HangHoas, "MaHangHoa", "TenHangHoa", chiTietBaoCaoTonKho.MaHangHoa);
     return(View(chiTietBaoCaoTonKho));
 }
示例#3
0
        // GET: ChiTietBaoCaoTonKho/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChiTietBaoCaoTonKho chiTietBaoCaoTonKho = db.ChiTietBaoCaoTonKhoes.Find(id);

            if (chiTietBaoCaoTonKho == null)
            {
                return(HttpNotFound());
            }
            return(View(chiTietBaoCaoTonKho));
        }
示例#4
0
        // GET: ChiTietBaoCaoTonKho/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChiTietBaoCaoTonKho chiTietBaoCaoTonKho = db.ChiTietBaoCaoTonKhoes.Find(id);

            if (chiTietBaoCaoTonKho == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaBaoCaoTonKho = new SelectList(db.BaoCaoTonKhoes, "MaBaoCaoTonKho", "MaBaoCaoTonKho", chiTietBaoCaoTonKho.MaBaoCaoTonKho);
            ViewBag.MaHangHoa      = new SelectList(db.HangHoas, "MaHangHoa", "TenHangHoa", chiTietBaoCaoTonKho.MaHangHoa);
            return(View(chiTietBaoCaoTonKho));
        }
 public bool Insert(ChiTietBaoCaoTonKho ctbcTonKho)
 {
     return(_connect.Update("SP_CHITIETBAOCAOTONKHO_INS", ctbcTonKho));
 }
示例#6
0
        private void btnLapBaoCao_Click(object sender, EventArgs e)
        {
            if (cbbThang.Text == "")
            {
                MessageBox.Show("Vui lòng chọn tháng!");
                return;
            }
            thang = int.Parse(cbbThang.Text);
            if (cbbNam.Text == "")
            {
                MessageBox.Show("Vui lòng chọn năm!");
                return;
            }
            nam = int.Parse(cbbNam.Text);
            DateTime dateStart = new DateTime(nam, thang, 1);
            DateTime dateEnd   = new DateTime(nam, thang, ProjectUltil.soNgay(nam, thang));

            if (dateStart > DateTime.Now.Date)
            {
                MessageBox.Show("Thời gian phải trước ngày hiện tại!");
                return;
            }
            //if(dateEnd > DateTime.Now.Date)
            //{
            //    dateEnd = DateTime.Now.Date;
            //}
            dsPhieuNhap    = PhieuNhapService.Search(null, dateStart, dateEnd);
            dsPhieuXuat    = PhieuXuatService.Search(null, dateStart, dateEnd);
            dsBaoCaoTonKho = BaoCaoTonKhoService.GetByMonthYear(thang, nam);
            dsHangHoa      = HangHoaService.LoadDataTable();
            if (dsBaoCaoTonKho.Rows.Count > 0)
            {
                grcBaoCaoTonKho.DataSource = ChiTietBaoCaoTonKhoService.GetById(dsBaoCaoTonKho.Rows[0].Field <int>("MaBaoCaoTonKho"));
                btnIn.Enabled = true;
            }
            else
            {
                bctk            = new BaoCaoTonKho();
                bctk.MaNhanVien = (ProjectUltil.MaNhanVien != "") ? ProjectUltil.MaNhanVien : "NV0001";
                bctk.Nam        = nam;
                bctk.Thang      = thang;
                bctk.NgayLap    = DateTime.Now.Date;
                if ((bctk.MaBaoCaoTonKho = BaoCaoTonKhoService.Insert(bctk)) != -1)
                {
                    for (int i = 0; i < dsHangHoa.Rows.Count; i++)
                    {
                        ctbctk = new ChiTietBaoCaoTonKho();
                        ctbctk.MaBaoCaoTonKho = bctk.MaBaoCaoTonKho;
                        ctbctk.MaHangHoa      = dsHangHoa.Rows[i].Field <string>("MaHangHoa");
                        ctbctk.SoLuongDauKy   = 0;
                        for (int j = 0; j < dsPhieuNhap.Rows.Count; j++)
                        {
                            dsCTPhieuNhap = ChiTietPhieuNhapService.GetById(dsPhieuNhap.Rows[j].Field <string>("SoPhieuNhap"));
                            for (int k = 0; k < dsCTPhieuNhap.Rows.Count; k++)
                            {
                                if (dsCTPhieuNhap.Rows[k].Field <string>("MaHangHoa") == ctbctk.MaHangHoa)
                                {
                                    int soluong = dsCTPhieuNhap.Rows[k].Field <int>("SoLuong");
                                    ctbctk.SoLuongNhap += soluong;
                                }
                            }
                        }

                        for (int j = 0; j < dsPhieuXuat.Rows.Count; j++)
                        {
                            dsCTPhieuXuat = ChiTietPhieuXuatService.GetById(dsPhieuXuat.Rows[j].Field <string>("SoPhieuXuat"));
                            for (int k = 0; k < dsCTPhieuXuat.Rows.Count; k++)
                            {
                                if (dsCTPhieuXuat.Rows[k].Field <string>("MaHangHoa") == ctbctk.MaHangHoa)
                                {
                                    int soluong = dsCTPhieuXuat.Rows[k].Field <int>("SoLuong");
                                    ctbctk.SoLuongXuat += soluong;
                                }
                            }
                        }

                        ctbctk.SoLuongCuoiKy = ctbctk.SoLuongDauKy + ctbctk.SoLuongNhap - ctbctk.SoLuongXuat;
                        if (!ChiTietBaoCaoTonKhoService.Insert(ctbctk))
                        {
                            ChiTietBaoCaoTonKhoService.Delete(ctbctk.MaBaoCaoTonKho.ToString());
                            BaoCaoTonKhoService.Delete(ctbctk.MaBaoCaoTonKho.ToString());
                            MessageBox.Show("Không thể thêm chi tiết báo cáo!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Không thể lập báo cáo!");
                }
                grcBaoCaoTonKho.DataSource = ChiTietBaoCaoTonKhoService.GetById(bctk.MaBaoCaoTonKho);
                btnIn.Enabled = true;
            }
        }
 public static bool Insert(ChiTietBaoCaoTonKho ctBaoCaoTonKho)
 {
     return(Controller.Insert(ctBaoCaoTonKho));
 }