コード例 #1
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            IPVCService us  = new PVCService(Settings.Default.db, Session["user"] as User);
            PVC         pvc = us.FindById(id);

            try
            {
                bool isSucceed = us.DeleteById(id);

                if (isSucceed)
                {
                    ViewBag.msg = "删除成功";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.msg = "删除失败";

                    return(View(pvc));
                }
            }
            catch (Exception)
            {
                ViewBag.msg = "删除异常";

                return(View(pvc));
            }
        }
コード例 #2
0
        public ActionResult Edit(int id)
        {
            IPVCService us   = new PVCService(Settings.Default.db, Session["user"] as User);
            PVC         user = us.FindById(id);

            return(View(user));
        }
コード例 #3
0
        // GET: PVC/Delete/5
        public ActionResult Delete(int id)
        {
            IPVCService us = new PVCService(Settings.Default.db, Session["user"] as User);

            PVC pvc = us.FindById(id);

            return(View(pvc));
        }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "id, name, shipDate, shipAmount, unit, batchNo, startTimeStr, endTimeStr, brand")] PVC pvc)
        {
            ResultMessage msg  = new ResultMessage();
            IPVCService   us   = new PVCService(Settings.Default.db, Session["user"] as User);
            PVC           pvcs = us.FindById(pvc.id);

            try
            {
                if (string.IsNullOrWhiteSpace(pvc.name))
                {
                    ViewBag.msg = "收货人姓名 不能为空";
                    return(View());
                }
                if (string.IsNullOrWhiteSpace(pvc.shipDate.ToString()))
                {
                    ViewBag.msg = "发货日期 不能为空";
                    return(View());
                }
                if (string.IsNullOrWhiteSpace(pvc.shipAmount.ToString()))
                {
                    ViewBag.msg = "发货数量 不能为空";
                    return(View());
                }

                if (string.IsNullOrWhiteSpace(pvc.batchNo))
                {
                    ViewBag.msg = "线别/批号 不能为空";
                    return(View());
                }

                if (string.IsNullOrWhiteSpace(Request.Form["startTimeStr"].ToString()))
                {
                    ViewBag.msg = "开始时间 不能为空";
                    return(View());
                }

                if (string.IsNullOrWhiteSpace(Request.Form["endTimeStr"].ToString()))
                {
                    ViewBag.msg = "结束时间 不能为空";
                    return(View());
                }

                if (string.IsNullOrWhiteSpace(pvc.brand))
                {
                    ViewBag.msg = "品名 不能为空";
                    return(View());
                }

                User        user    = Session["user"] as User;
                IPVCService service = new PVCService(Settings.Default.db, user);

                pvc.peNum = pvc.batchNo.Trim() + "." + Request.Form["startTimeStr"].Trim().ToString() + "-" + Request.Form["endTimeStr"].Trim().ToString();

                pvc.startTime = DateTime.ParseExact(Request.Form["startTimeStr"].Trim().ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                pvc.endTime   = DateTime.ParseExact(Request.Form["endTimeStr"].Trim().ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);

                //pvcs.name = pvc.name;
                //pvcs.shipDate = pvc.shipDate;
                //pvcs.shipAmount = pvc.shipAmount;
                //pvcs.unit = pvc.unit;
                //pvcs.peNum = pvc.peNum;
                //pvcs.batchNo = pvc.batchNo;
                //pvcs.startTime = pvc.startTime;
                //pvcs.endTime = pvc.endTime;
                //pvcs.brand = pvc.brand;
                //pvcs.name = pvc.name;

                //可以添加操作日志
                bool isSucceed = us.Update(pvc);

                if (isSucceed)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.msg = "更新失败";
                    return(View(pvcs));
                }
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex;

                return(View(pvcs));
            }
        }