Example #1
0
        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);
            }
        }
Example #2
0
        public ActionResult AddEditCustomerBillScheme(int custId)
        {
            //this.Internationalization();

            #region Add

            if (Request.Form["oper"].Equals("add"))
            {
                try
                {
                    //重名了
                    if (true == CheckBillingTemplateName(custId, Request.Form["BillingTemplateName"].Trim(), -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 = Request.Form["BillingTemplateCode"].Trim();
                            cstmer.BillingTemplateName = Request.Form["BillingTemplateName"].Trim();
                            cstmer.BillingTemplateTypeID = Util.toint(Request.Form["BillingTemplateTypeID"].Trim());

                            cstmer.CreateDate = cstmer.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                            cstmer.CustomerID = custId; // Convert.ToInt32(customerId);
                            cstmer.TemplateCreditContent = Request.Form["TemplateCreditContent"].Trim();
                            cstmer.TimeTypeID = Util.toint(Request.Form["TimeTypeID"].Trim());

                            cstmer.Discount = Convert.ToDouble(Request.Form["Discount"].Trim());

                            cstmer.Remark = Request.Form["Remark"].Trim();
                            cstmer.OwnerID = -1;
                            cstmer.UserID = Session.GetDataFromSession<int>("userid");
                            cstmer.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                            cstmer.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                            cstmer.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                            cstmer.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

                            if (Request.Form["UserDefinedCol5"].Trim() != "")
                                cstmer.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                            if (Request.Form["UserDefinedCol6"].Trim() != "")
                                cstmer.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                            if (Request.Form["UserDefinedCol7"].Trim() != "")
                                cstmer.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                            if (Request.Form["UserDefinedCol8"].Trim() != "")
                                cstmer.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                            cstmer.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim();
                            cstmer.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim();

                            cstmer = db.BillingTemplate.Add(cstmer);
                            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["BillingTemplateIDX"]);
                    BillingTemplate cstmer = db.BillingTemplate.Where(u => u.IDX == idx).FirstOrDefault();

                    if (cstmer == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    //重名了
                    if (true == CheckBillingTemplateName(Util.toint(Request.Form["CustomerID"].Trim()), Request.Form["BillingTemplateName"].Trim(), idx))
                    {
                        return Json(new { code = Resources.Common.FAIL_CODE, message = Resources.Common.FAIL_MESSAGE });
                    }
                    else
                    {
                        cstmer.BillingTemplateCode = Request.Form["BillingTemplateCode"].Trim();
                        cstmer.BillingTemplateName = Request.Form["BillingTemplateName"].Trim();
                        cstmer.BillingTemplateTypeID = Util.toint(Request.Form["BillingTemplateTypeID"].Trim());

                        cstmer.CustomerID = Util.toint(Request.Form["CustomerID"].Trim());
                        cstmer.TemplateCreditContent = Request.Form["TemplateCreditContent"].Trim();
                        cstmer.TimeTypeID = Util.toint(Request.Form["TimeTypeID"].Trim());

                        cstmer.Discount = Convert.ToDouble(Request.Form["Discount"].Trim());
                        cstmer.ShipLength = (Request.Form["ShipLength"]);
                        cstmer.ShipTEUS = (Request.Form["ShipTEUS"]);
                        cstmer.ExpiryDate = Request.Form["ExpiryDate"].Trim();

                        cstmer.Remark = Request.Form["Remark"].Trim();
                        cstmer.OwnerID = -1;
                        cstmer.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        cstmer.UserID = Session.GetDataFromSession<int>("userid");
                        cstmer.UserDefinedCol1 = Request.Form["UserDefinedCol1"].Trim();
                        cstmer.UserDefinedCol2 = Request.Form["UserDefinedCol2"].Trim();
                        cstmer.UserDefinedCol3 = Request.Form["UserDefinedCol3"].Trim();
                        cstmer.UserDefinedCol4 = Request.Form["UserDefinedCol4"].Trim();

                        if (Request.Form["UserDefinedCol5"].Trim() != "")
                            cstmer.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"].Trim());

                        if (Request.Form["UserDefinedCol6"].Trim() != "")
                            cstmer.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"].Trim());

                        if (Request.Form["UserDefinedCol7"].Trim() != "")
                            cstmer.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"].Trim());

                        if (Request.Form["UserDefinedCol8"].Trim() != "")
                            cstmer.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"].Trim());

                        cstmer.UserDefinedCol9 = Request.Form["UserDefinedCol9"].Trim();
                        cstmer.UserDefinedCol10 = Request.Form["UserDefinedCol10"].Trim();

                        db.Entry(cstmer).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                    }
                }
                catch (Exception)
                {
                    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 });
        }