Ejemplo n.º 1
0
        // GET: BillPropertyModels/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BillPropertyModels billPropertyModels = db.BillProperties.Find(id);

            if (billPropertyModels == null)
            {
                return(HttpNotFound());
            }
            List <CodeMethod>     list = CodeMethod.GetBillType();
            List <SelectListItem> item = list.Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = c.Description
            }).ToList();

            foreach (var tmp in item)
            {
                if (billPropertyModels.CodeMethod == tmp.Text)
                {
                    tmp.Selected = true;
                    break;
                }
            }
            ViewBag.List = item;
            return(View(billPropertyModels));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(BillPropertyModels billPropertyModels)
        {
            if (ModelState.IsValid)
            {
                switch (billPropertyModels.CodeMethod)
                {
                case CodeMethod.Month:
                    billPropertyModels.Year         = 2;
                    billPropertyModels.Month        = 2;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = 6;
                    break;

                case CodeMethod.Serial:
                    billPropertyModels.Year         = 0;
                    billPropertyModels.Month        = 0;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = this.GetSerialNumbers(billPropertyModels.Code);
                    break;

                case CodeMethod.Manual:
                    billPropertyModels.Year         = 0;
                    billPropertyModels.Month        = 0;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = 0;
                    break;

                default:
                    billPropertyModels.Year         = 2;
                    billPropertyModels.Month        = 2;
                    billPropertyModels.Day          = 2;
                    billPropertyModels.SerialNumber = 4;
                    break;
                }
                db.Entry(billPropertyModels).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <CodeMethod>     list = CodeMethod.GetBillType();
            List <SelectListItem> item = list.Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = c.Description
            }).ToList();

            foreach (var tmp in item)
            {
                if (billPropertyModels.CodeMethod == tmp.Text)
                {
                    tmp.Selected = true;
                    break;
                }
            }
            ViewBag.List = item;
            return(View(billPropertyModels));
        }
Ejemplo n.º 3
0
        // GET: BillPropertyModels/Create
        public ActionResult Create()
        {
            List <CodeMethod>     list = CodeMethod.GetBillType();
            List <SelectListItem> item = list.Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = c.Description
            }).ToList();

            ViewBag.List         = item;
            ViewBag.BillSortList = BillSortMethod.GetBillSortMethod(base.ConnectionString);
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Create(BillPropertyModels billPropertyModels)
        {
            if (ModelState.IsValid)
            {
                switch (billPropertyModels.CodeMethod)
                {
                case CodeMethod.Month:
                    billPropertyModels.Year         = 2;
                    billPropertyModels.Month        = 2;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = 6;
                    break;

                case CodeMethod.Serial:
                    billPropertyModels.Year         = 0;
                    billPropertyModels.Month        = 0;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = this.GetSerialNumbers(billPropertyModels.Code);
                    break;

                case CodeMethod.Manual:
                    billPropertyModels.Year         = 0;
                    billPropertyModels.Month        = 0;
                    billPropertyModels.Day          = 0;
                    billPropertyModels.SerialNumber = 0;
                    break;

                default:
                    billPropertyModels.Year         = 2;
                    billPropertyModels.Month        = 2;
                    billPropertyModels.Day          = 2;
                    billPropertyModels.SerialNumber = 4;
                    break;
                }
                //获取单据的编号值
                BillSort tmpBillSort = db.BillSorts.Find(billPropertyModels.BillSort);
                string   num         = tmpBillSort.SerialNumber.ToString();
                if (num.Length == 1)
                {
                    num = num.Insert(0, "0");
                }
                //更新BillSort表中某一类型单据可用的最大编号值
                tmpBillSort.SerialNumber   += 2;
                db.Entry(tmpBillSort).State = EntityState.Modified;

                //拼凑出真实的单据性质编号(单据的类型编号+单据的可用最大编号值)
                billPropertyModels.Type = billPropertyModels.BillSort + num;

                db.BillProperties.Add(billPropertyModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <CodeMethod>     list = CodeMethod.GetBillType();
            List <SelectListItem> item = list.Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = c.Description
            }).ToList();

            ViewBag.List         = item;
            ViewBag.BillSortList = BillSortMethod.GetBillSortMethod(base.ConnectionString);

            return(View(billPropertyModels));
        }