public ActionResult AddEditCustomerBillSchemeItem() { this.Internationalization(); #region Add if (Request.Form["oper"].Equals("add")) { try { TugDataEntities db = new TugDataEntities(); { TugDataModel.BillingItemTemplate aScheduler = new BillingItemTemplate(); aScheduler.BillingTemplateID = Util.toint(Request.Form["BillingTemplateID"].Trim()); aScheduler.ItemID = Util.toint(Request.Form["ItemID"].Trim()); aScheduler.UnitPrice = Convert.ToDouble(Request.Form["UnitPrice"].Trim()); aScheduler.Currency = Request.Form["Currency".Trim()]; aScheduler.TypeID = Util.toint(Request.Form["TypeID"].Trim()); aScheduler.OwnerID = -1; aScheduler.UserID = Session.GetDataFromSession<int>("userid"); aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); aScheduler.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim(); aScheduler.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim(); aScheduler.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim(); aScheduler.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim(); if (Request.Form["UserDefinedCol5"].Trim() != "") aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim()); if (Request.Form["UserDefinedCol6"].Trim() != "") aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim()); if (Request.Form["UserDefinedCol7"].Trim() != "") aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim()); if (Request.Form["UserDefinedCol8"].Trim() != "") aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim()); aScheduler.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim(); aScheduler.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim(); aScheduler = db.BillingItemTemplate.Add(aScheduler); db.SaveChanges(); var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE }; //Response.Write(@Resources.Common.SUCCESS_MESSAGE); return Json(ret); } } catch (Exception) { var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE }; //Response.Write(@Resources.Common.EXCEPTION_MESSAGE); return Json(ret); } } #endregion Add #region Edit if (Request.Form["oper"].Equals("edit")) { try { TugDataEntities db = new TugDataEntities(); int idx = Util.toint(Request.Form["IDX"]); BillingItemTemplate aScheduler = db.BillingItemTemplate.Where(u => u.IDX == idx).FirstOrDefault(); if (aScheduler == null) { return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE }); } else { aScheduler.BillingTemplateID = Util.toint(Request.Form["BillingTemplateID"].Trim()); aScheduler.ItemID = Util.toint(Request.Form["ItemID"].Trim()); aScheduler.UnitPrice = Convert.ToDouble(Request.Form["UnitPrice"].Trim()); aScheduler.Currency = Request.Form["Currency"].Trim(); aScheduler.TypeID = Util.toint(Request.Form["TypeID"].Trim()); aScheduler.OwnerID = -1; aScheduler.UserID = Session.GetDataFromSession<int>("userid"); aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); aScheduler.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim(); aScheduler.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim(); aScheduler.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim(); aScheduler.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim(); if (Request.Form["UserDefinedCol5"].Trim() != "") aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim()); if (Request.Form["UserDefinedCol6"].Trim() != "") aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim()); if (Request.Form["UserDefinedCol7"].Trim() != "") aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim()); if (Request.Form["UserDefinedCol8"].Trim() != "") aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim()); aScheduler.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim(); aScheduler.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim(); db.Entry(aScheduler).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE }); } } catch (Exception exp) { return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE }); } } #endregion Edit return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE }); }
public ActionResult AddCustomerBillScheme(int custId, int billingTemplateTypeId, string billingTemplateCode, string billingTemplateName, int timeTypeId, double discount, string shipLength, string shipTEUS, string expiryDate, string templateCreditContent, string remark, List<string[]> dataListFromTable) { try { //重名了 if (true == CheckBillingTemplateName(custId, billingTemplateName, -1)) { return Json(new { code = Resources.Common.FAIL_CODE, message = Resources.Common.FAIL_MESSAGE }); } else { TugDataEntities db = new TugDataEntities(); TugDataModel.BillingTemplate cstmer = new BillingTemplate(); cstmer.BillingTemplateCode = billingTemplateCode; cstmer.BillingTemplateName = billingTemplateName; cstmer.BillingTemplateTypeID = billingTemplateTypeId; cstmer.ShipLength = shipLength; cstmer.ShipTEUS = shipTEUS; cstmer.ExpiryDate = expiryDate; cstmer.CreateDate = cstmer.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); cstmer.CustomerID = custId; // Convert.ToInt32(customerId); cstmer.TemplateCreditContent = templateCreditContent; cstmer.TimeTypeID = timeTypeId; cstmer.Discount = discount; cstmer.Remark = remark; cstmer.OwnerID = -1; cstmer.UserID = Session.GetDataFromSession<int>("userid"); cstmer.UserDefinedCol1 = ""; cstmer.UserDefinedCol2 = ""; cstmer.UserDefinedCol3 = ""; cstmer.UserDefinedCol4 = ""; //if (Request.Form["UserDefinedCol5"] != "") // cstmer.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]); //if (Request.Form["UserDefinedCol6"] != "") // cstmer.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"]); //if (Request.Form["UserDefinedCol7"] != "") // cstmer.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"]); //if (Request.Form["UserDefinedCol8"] != "") // cstmer.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"]); cstmer.UserDefinedCol9 = ""; cstmer.UserDefinedCol10 = ""; cstmer = db.BillingTemplate.Add(cstmer); db.SaveChanges(); //保存收费项 for (int i = 0; i < dataListFromTable.Count - 1; i++)//最后一行空行 { if (Util.checkdbnull(dataListFromTable[i][2]) == "") continue; TugDataModel.BillingItemTemplate aScheduler = new BillingItemTemplate(); aScheduler.BillingTemplateID = cstmer.IDX; aScheduler.ItemID =Util.toint(dataListFromTable[i][0]); aScheduler.UnitPrice = Util.tonumeric(dataListFromTable[i][2]); aScheduler.Currency = dataListFromTable[i][3]; aScheduler.TypeID = 13; aScheduler.OwnerID = -1; aScheduler.UserID = Session.GetDataFromSession<int>("userid"); aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); aScheduler.UserDefinedCol1 = ""; aScheduler.UserDefinedCol2 = ""; aScheduler.UserDefinedCol3 = ""; aScheduler.UserDefinedCol4 = ""; //if (Request.Form["UserDefinedCol5"] != "") // aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]); //if (Request.Form["UserDefinedCol6"] != "") // aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"]); //if (Request.Form["UserDefinedCol7"] != "") // aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"]); //if (Request.Form["UserDefinedCol8"] != "") // aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"]); aScheduler.UserDefinedCol9 = ""; aScheduler.UserDefinedCol10 = ""; aScheduler = db.BillingItemTemplate.Add(aScheduler); db.SaveChanges(); } var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE }; //Response.Write(@Resources.Common.SUCCESS_MESSAGE); return Json(ret); } } catch (Exception) { var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE }; //Response.Write(@Resources.Common.EXCEPTION_MESSAGE); return Json(ret); } }
public ActionResult AddCustomerBillSchemeItem(int billingTemplateId, int itemId, string unitPrice, string currency, int typeId) { this.Internationalization(); try { TugDataEntities db = new TugDataEntities(); { TugDataModel.BillingItemTemplate aScheduler = new BillingItemTemplate(); aScheduler.BillingTemplateID = billingTemplateId; aScheduler.ItemID = itemId; aScheduler.UnitPrice = Convert.ToDouble(unitPrice); aScheduler.Currency = currency; aScheduler.TypeID = typeId; aScheduler.OwnerID = -1; aScheduler.UserID = Session.GetDataFromSession<int>("userid"); aScheduler.CreateDate = aScheduler.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); aScheduler.UserDefinedCol1 = ""; aScheduler.UserDefinedCol2 = ""; aScheduler.UserDefinedCol3 = ""; aScheduler.UserDefinedCol4 = ""; //if (Request.Form["UserDefinedCol5"] != "") // aScheduler.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]); //if (Request.Form["UserDefinedCol6"] != "") // aScheduler.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"]); //if (Request.Form["UserDefinedCol7"] != "") // aScheduler.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"]); //if (Request.Form["UserDefinedCol8"] != "") // aScheduler.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"]); aScheduler.UserDefinedCol9 = ""; aScheduler.UserDefinedCol10 = ""; aScheduler = db.BillingItemTemplate.Add(aScheduler); db.SaveChanges(); var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE }; //Response.Write(@Resources.Common.SUCCESS_MESSAGE); return Json(ret); } } catch (Exception ex) { var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE }; //Response.Write(@Resources.Common.EXCEPTION_MESSAGE); return Json(ret); } return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE }); }