예제 #1
0
        public void CreateTest()
        {
            SaleReturnVM vm = _controller.Wtm.CreateVM <SaleReturnVM>();
            SaleReturn   v  = new SaleReturn();

            v.SRID        = "qH2ATmQ";
            v.CustomersID = AddCustomers();
            v.DepotsID    = AddDepots();
            v.SRState     = SCMSupplyChain.Model.SRState.未定义3;
            v.SRDesc      = "jubk";
            vm.Entity     = v;
            var rv = _controller.Add(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <SaleReturn>().Find(v.ID);

                Assert.AreEqual(data.SRID, "qH2ATmQ");
                Assert.AreEqual(data.SRState, SCMSupplyChain.Model.SRState.未定义3);
                Assert.AreEqual(data.SRDesc, "jubk");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
        public async Task <IActionResult> Create(int?id)
        {
            string CompId = User.Claims.Where(r => r.Type == "CompanyID").FirstOrDefault().Value;
            int    CompID = Convert.ToInt32(CompId);

            if (id == null)
            {
                return(NotFound());
            }
            SaleReturnVM model    = new SaleReturnVM();
            SaleBill     saleBill = new SaleBill();

            saleBill = await _context.SaleBill.Where(r => r.CompanyID == CompID).Include(r => r.Parties).FirstOrDefaultAsync(m => m.SaleBillID == id);

            if (saleBill == null)
            {
                return(NotFound());
            }

            model.SaleBillID = saleBill.SaleBillID;

            model.BillDate_OldBill = saleBill.BillDate.ToString("d");

            model.ContactNumber_OldBill = saleBill.ContactNumber;
            model.ContactPerson_OldBill = saleBill.ContactPerson;
            model.GrossTotal_OldBill    = saleBill.GrossTotal;
            model.NetAmount_OldBill     = saleBill.NetAmount;

            if (saleBill.PartiesID == null)
            {
                model.PartiesID = null;
                model.SR_S_1    = "Cash Sale";
            }
            else
            {
                model.PartiesID = saleBill.PartiesID;
                model.SR_S_1    = saleBill.Parties.PartyName;
            }

            model.Remarks_OldBill       = saleBill.Remarks;
            model.TDiscount_OldBill     = saleBill.TDiscount;
            model.TotalQuantity_OldBill = saleBill.TotalQuantity;

            model.SaleBillItem_List = _context.SaleBillItem.Include(r => r.Item).Where(r => r.SaleBillID == id).ToList();

            ViewData["Ids"]        = _context.Bank.Where(r => r.CompanyID == CompID).Select(m => m.BankID).ToList();
            ViewData["Name"]       = _context.Bank.Where(r => r.CompanyID == CompID).Select(m => m.BankName).ToList();
            ViewData["BankID"]     = new SelectList(_context.Bank.Where(r => r.CompanyID == CompID), "BankID", "BankName");
            ViewData["CurrencyID"] = new SelectList(_context.Currency, "CurrencyID", "CurrencyName", saleBill.CurrencyID);
            //ViewData["PartiesID"] = new SelectList(_context.Parties, "PartiesID", "PartyName", saleBill.PartiesID);

            ViewData["ItemID"]     = new SelectList(_context.Item.Where(r => r.CompanyID == CompID), "ItemID", "ItemID");
            ViewData["PartiesID"]  = new SelectList(_context.Parties.Where(r => r.CompanyID == CompID), "PartiesID", "PartyName");
            ViewData["SaleBillID"] = new SelectList(_context.PurchaseBill.Where(r => r.CompanyID == CompID), "SaleBillID", "SaleBillNo");
            return(View(model));
        }
예제 #3
0
        public void EditTest()
        {
            SaleReturn v = new SaleReturn();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.SRID        = "qH2ATmQ";
                v.CustomersID = AddCustomers();
                v.DepotsID    = AddDepots();
                v.SRState     = SCMSupplyChain.Model.SRState.未定义3;
                v.SRDesc      = "jubk";
                context.Set <SaleReturn>().Add(v);
                context.SaveChanges();
            }

            SaleReturnVM vm    = _controller.Wtm.CreateVM <SaleReturnVM>();
            var          oldID = v.ID;

            v    = new SaleReturn();
            v.ID = oldID;

            v.SRID    = "2Fx2f";
            v.SRState = SCMSupplyChain.Model.SRState.未定义3;
            v.SRDesc  = "L62";
            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

            vm.FC.Add("Entity.SRID", "");
            vm.FC.Add("Entity.CustomersID", "");
            vm.FC.Add("Entity.DepotsID", "");
            vm.FC.Add("Entity.SRState", "");
            vm.FC.Add("Entity.SRDesc", "");
            var rv = _controller.Edit(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <SaleReturn>().Find(v.ID);

                Assert.AreEqual(data.SRID, "2Fx2f");
                Assert.AreEqual(data.SRState, SCMSupplyChain.Model.SRState.未定义3);
                Assert.AreEqual(data.SRDesc, "L62");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
예제 #4
0
 public IActionResult Edit(SaleReturnVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorJson()));
     }
     else
     {
         vm.DoEdit(false);
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState.GetErrorJson()));
         }
         else
         {
             return(Ok(vm.Entity));
         }
     }
 }