예제 #1
0
 public ActionResult VerifyExpenses(Off_Expenses model, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         Off_Expenses item = new Off_Expenses();
         if (TryUpdateModel(item))
         {
             var detailitemcnt = form.GetValues("detailid") == null ? 0 : form.GetValues("detailid").Length;
             for (int i = 0; i < detailitemcnt; i++)
             {
                 if (form.GetValues("detailid")[i] == "0")
                 {
                     Off_Expenses_Payment detailtemp = new Off_Expenses_Payment()
                     {
                         Off_Expenses    = item,
                         VerifyCost      = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString()),
                         VerifyType      = Convert.ToInt32(form.GetValues("detaillist")[i].ToString()),
                         ApplicationDate = Convert.ToDateTime(form.GetValues("apdate")[i]),
                         Remarks         = form.GetValues("detailremarks")[i].ToString(),
                         UploadTime      = DateTime.Now,
                         UploadUser      = User.Identity.Name
                     };
                     _offlineDB.Off_Expenses_Payment.Add(detailtemp);
                 }
                 else
                 {
                     int d_id = Convert.ToInt32(form.GetValues("detailid")[i]);
                     Off_Expenses_Payment detailstemp = _offlineDB.Off_Expenses_Payment.SingleOrDefault(m => m.Id == d_id);
                     detailstemp.VerifyCost              = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString());
                     detailstemp.VerifyType              = Convert.ToInt32(form.GetValues("detaillist")[i].ToString());
                     detailstemp.ApplicationDate         = Convert.ToDateTime(form.GetValues("apdate")[i]);
                     detailstemp.Remarks                 = form.GetValues("detailremarks")[i].ToString();
                     detailstemp.UploadTime              = DateTime.Now;
                     detailstemp.UploadUser              = User.Identity.Name;
                     _offlineDB.Entry(detailstemp).State = System.Data.Entity.EntityState.Modified;
                 }
             }
             item.UploadTime = DateTime.Now;
             item.UploadUser = User.Identity.Name;
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
             return(RedirectToAction("ExpensesIndex"));
         }
         else
         {
             ModelState.AddModelError("", "发生错误");
             return(View(model));
         }
     }
     else
     {
         ModelState.AddModelError("", "发生错误");
         return(View(model));
     }
 }
예제 #2
0
 public ActionResult EditExpenses(Off_Expenses model, FormCollection form)
 {
     if (ModelState.IsValid)
     {
         Off_Expenses item = new Off_Expenses();
         if (TryUpdateModel(item))
         {
             var detailitemcnt = form.GetValues("detailid") == null ? 0 : form.GetValues("detailid").Length;
             for (int i = 0; i < detailitemcnt; i++)
             {
                 if (form.GetValues("detailid")[i] == "0")
                 {
                     Off_Expenses_Details detailtemp = new Off_Expenses_Details()
                     {
                         Off_Expenses = item,
                         DetailsFee   = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString()),
                         DetailsName  = form.GetValues("detaillist")[i].ToString(),
                         Remarks      = form.GetValues("detailremarks")[i].ToString(),
                         UploadTime   = DateTime.Now,
                         UploadUser   = User.Identity.Name,
                         ExpensesType = 0
                     };
                     _offlineDB.Off_Expenses_Details.Add(detailtemp);
                 }
                 else
                 {
                     int d_id = Convert.ToInt32(form.GetValues("detailid")[i]);
                     Off_Expenses_Details detailstemp = _offlineDB.Off_Expenses_Details.SingleOrDefault(m => m.Id == d_id);
                     detailstemp.DetailsFee              = Convert.ToDecimal(form.GetValues("detailfee")[i].ToString());
                     detailstemp.DetailsName             = form.GetValues("detaillist")[i].ToString();
                     detailstemp.Remarks                 = form.GetValues("detailremarks")[i].ToString();
                     detailstemp.UploadTime              = DateTime.Now;
                     detailstemp.UploadUser              = User.Identity.Name;
                     _offlineDB.Entry(detailstemp).State = System.Data.Entity.EntityState.Modified;
                 }
             }
             item.UploadTime = DateTime.Now;
             item.UploadUser = User.Identity.Name;
             _offlineDB.Entry(item).State = System.Data.Entity.EntityState.Modified;
             _offlineDB.SaveChanges();
         }
         return(RedirectToAction("ExpensesIndex"));
     }
     else
     {
         ModelState.AddModelError("", "发生错误");
         List <Object> attendance = new List <Object>();
         attendance.Add(new { Key = 0, Value = "进场费" });
         attendance.Add(new { Key = 1, Value = "活动费" });
         ViewBag.PayType = new SelectList(attendance, "Key", "Value", model.Status);
         return(View(model));
     }
 }
예제 #3
0
        public ActionResult AddExpensesPartial(FormCollection form)
        {
            var user = UserManager.FindById(User.Identity.GetUserId());
            var item = new Off_Expenses();

            if (TryUpdateModel(item))
            {
                item.Status        = 0;
                item.UploadTime    = DateTime.Now;
                item.UploadUser    = User.Identity.Name;
                item.Off_System_Id = user.DefaultSystemId;
                _offlineDB.Off_Expenses.Add(item);
                _offlineDB.SaveChanges();
                return(Content("SUCCESS"));
            }
            return(Content("FAIL"));
        }