コード例 #1
0
ファイル: BillDetailService.cs プロジェクト: tw0r2/wms_rfid
        public bool Save(BillDetail billDetail, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  b      = BillDetailRepository.GetQueryable().FirstOrDefault(c => c.BillMaster.UUID == billDetail.BillMaster.UUID);

            if (b != null)
            {
                try
                {
                    b.PieceCigarCode = billDetail.PieceCigarCode;
                    b.BoxCigarCode   = billDetail.BoxCigarCode;
                    b.BillQuantity   = billDetail.BillQuantity;
                    b.FixedQuantity  = billDetail.FixedQuantity;
                    b.RealQuantity   = billDetail.RealQuantity;

                    BillDetailRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: BillDetailService.cs プロジェクト: tw0r2/wms_rfid
        public bool Add(BillDetail billDetail, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  b      = new BillDetail();

            if (b != null)
            {
                try
                {
                    b.ID             = billDetail.ID;
                    b.MasterID       = billDetail.MasterID;
                    b.PieceCigarCode = billDetail.PieceCigarCode;
                    b.BoxCigarCode   = billDetail.BoxCigarCode;
                    b.BillQuantity   = billDetail.BillQuantity;
                    b.FixedQuantity  = billDetail.FixedQuantity;
                    b.RealQuantity   = billDetail.RealQuantity;

                    BillDetailRepository.Add(b);
                    BillDetailRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.ToString();
                    result    = false;
                }
            }
            else
            {
                strResult = "原因:找不到当前登陆用户!请重新登陆!";
                result    = false;
            }
            return(result);
        }
コード例 #3
0
        public ActionResult Create(BillViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Db = new ApricotContext();
                FillBillsViewModel fbvm = new FillBillsViewModel(Db);
                fbvm.CreateNewBill(User.Identity.Name, model);

                //Get BillID
                BillDetailRepository billdetailrepo = new BillDetailRepository(Db);
                var billdetail = billdetailrepo.GetAll().Where(bd => (bd.Bill_Date == model.BillDate &&
                                                                      bd.Bill_Type == model.BillType &&
                                                                      bd.Bill_ModeOfPayment == model.ModeOfPayment));
                model.BillID = billdetail.Select(bd => bd.Bill_ID).Single();

                //Create Notification for New Bill
                NotificationBL notibl = new NotificationBL(Db);
                notibl.NotifyManager(model.BillID);

                return(RedirectToAction("Index"));
            }

            //Something Went wrong, redisplay form
            return(View(model));
        }
コード例 #4
0
        public void CreateNewBill(string username, BillViewModel model)
        {
            //get Employee
            EmployeeRepository employeerepo = new EmployeeRepository(_context);
            var employee = employeerepo.GetByEmpNo(username);
            var empId    = employee.Emp_ID;

            //Create Bill
            BillRepository billrepo = new BillRepository(_context);
            Bill           bill     = new Bill();

            bill.Bill_Status = model.BillStatus;
            bill.Emp_ID      = empId;

            billrepo.AddBill(bill);

            //Create Bill Details
            BillDetailRepository billdetailrepo = new BillDetailRepository(_context);
            Bill_Detail          billdetail     = new Bill_Detail()
            {
                Bill_Amount        = model.BillAmount,
                Bill_Date          = model.BillDate,
                Bill_ModeOfPayment = model.ModeOfPayment,
                Bill_Type          = model.BillType,
                Bill_ID            = bill.Bill_ID,
                Bill_have_SCopy    = (model.BillSCopy != null) ? true : false,
            };

            billdetailrepo.AddBillDetail(billdetail);

            //Add Scanned Copy
            if (billdetail.Bill_have_SCopy)
            {
                BillSCopyRepository bscopyrepo = new BillSCopyRepository(_context);
                Bill_SCopy          billscopy  = new Bill_SCopy()
                {
                    Bill_ID = bill.Bill_ID,
                    SCopy   = model.BillSCopy
                };
                bscopyrepo.AddBillSCopy(billscopy);
            }

            //Add Bill Manager
            //get Manager's EmpID

            String[] emp_no_name = model.Manager.Split('-');
            var      ManagerId   = employeerepo.GetByEmpNo(emp_no_name[0]).Emp_ID;

            BillMRepository bmrepo = new BillMRepository(_context);

            Bill_M billm = new Bill_M();

            billm.Bill_ID = bill.Bill_ID;
            billm.Emp_ID  = ManagerId;

            bmrepo.AddBillM(billm);
        }
コード例 #5
0
 public UnitOfWork(SmartAccountContext context)
 {
     _context           = context;
     AccountMasters     = new AccountMasterRepository(_context);
     BillDetails        = new BillDetailRepository(_context);
     BillMasters        = new BillMasterRepository(_context);
     CgstMasters        = new CgstMasterRepository(_context);
     Companies          = new CompanyRepository(_context);
     Ledgers            = new LedgerRepository(_context);
     SgstMasters        = new SgstMasterRepository(_context);
     IgstMasters        = new IgstMasterRepository(_context);
     TransactionMasters = new TransactionMasterRepository(_context);
     TypeMasters        = new TypeMasterRepository(_context);
     Users          = new UserRepository(_context);
     VoucherDetails = new VoucherDetailRepository(_context);
     VoucherMasters = new VoucherMasterRepository(_context);
 }
コード例 #6
0
        public BillViewModel getBillDetail(Int64 id)
        {
            BillRepository       billrepo       = new BillRepository(_context);
            BillDetailRepository billdetailrepo = new BillDetailRepository(_context);
            BillMRepository      billmrepo      = new BillMRepository(_context);
            BillFMRepository     billfmrepo     = new BillFMRepository(_context);
            BillSCopyRepository  billscopyrepo  = new BillSCopyRepository(_context);
            BillViewModel        bvm            = new BillViewModel();

            Bill        bill         = billrepo.GetByBillID(id);
            Bill_Detail billdetail   = billdetailrepo.GetByBillID(id);
            Bill_M      billmanager  = billmrepo.GetByBillID(id);
            Bill_FM     billfmanager = null;
            Bill_SCopy  billscopy    = null;

            if (bill.Bill_Status == ApricotEnums.BillSatusEnum.APPROVED || bill.Bill_Status == ApricotEnums.BillSatusEnum.CLOSED)
            {
                billfmanager = billfmrepo.GetByBillId(id);
            }

            if (billdetail.Bill_have_SCopy)
            {
                billscopy = billscopyrepo.GetByBillID(id);
            }

            bvm.BillID        = bill.Bill_ID;
            bvm.BillStatus    = bill.Bill_Status;
            bvm.BillAmount    = billdetail.Bill_Amount;
            bvm.BillDate      = billdetail.Bill_Date;
            bvm.BillSCopy     = null;
            bvm.BillType      = billdetail.Bill_Type;
            bvm.FManager      = (billfmanager != null) ? billfmanager.FinanceManager.Emp_No : "Not Aviablable";
            bvm.Manager       = billmanager.Manager.Emp_Name;
            bvm.ModeOfPayment = billdetail.Bill_ModeOfPayment;

            return(bvm);
        }
コード例 #7
0
        public List <SanPham> StatisticalProduct(int Type, String MaSP, String DateStart, String DateEnd)
        {
            if (!ValidateDate(DateStart, DateEnd))
            {
                return(null);
            }
            List <SanPham> result = new List <SanPham>();

            if (Type == 3 || Type == 4)
            {
                result = _productrepository.ListProducts().ToList();
                if (MaSP != null)
                {
                    result = result.FindAll(c => c.MaSP.Equals(MaSP));
                }
                if (Type == 3)
                {
                    result.Sort(new SortDESC());
                }
                if (Type == 4)
                {
                    result.Sort(new SortASC());
                }
            }
            if (Type == 1 || Type == 2)
            {
                IBillDetailRespository _repository = new BillDetailRepository();
                foreach (ChiTietHoaDon item in _repository.ListBillDetail())
                {
                    if (item.HoaDon.NgayLap >= DateTime.Parse(DateStart) && item.HoaDon.NgayLap <= DateTime.Parse(DateEnd))
                    {
                        SanPham target = item.SanPham;
                        target.SoLuong = item.SoLuong;
                        target.DonGia  = item.DonGia;
                        SanPham index = result.Find(c => c.MaSP.Equals(target.MaSP));
                        if (index != null)
                        {
                            index.SoLuong = index.SoLuong + target.SoLuong;
                        }
                        else
                        {
                            result.Add(target);
                        }
                    }
                }
                if (MaSP != null)
                {
                    result = result.FindAll(c => c.MaSP.Equals(MaSP));
                }
                if (Type == 1)
                {
                    result.Sort(new SortDESC());
                }
                if (Type == 2)
                {
                    result.Sort(new SortASC());
                }
            }
            if (Type == 0)
            {
                result = _productrepository.ListProducts().ToList();
            }
            return(result);
        }