Beispiel #1
0
        public ActionResult Order_AddEdits(string str)
        {
            retValue ret = new retValue();

            PMS.Models.UserModel userModel = Session["UserModel"] as PMS.Models.UserModel;
            int userid = userModel._ID;

            BLL.OrderInfoBLL _BLL = new OrderInfoBLL();
            JObject          o    = null;

            if (!string.IsNullOrEmpty(str))
            {
                o = JObject.Parse(str);

                string ID         = o["ID"]._ToStrTrim();
                string NGUID      = o["NGUID"]._ToStrTrim();
                string CostID     = o["CostID"]._ToStrTrim();
                string Month      = o["Month"]._ToStrTrim();
                string OrderNum   = o["OrderNumber"]._ToStrTrim();
                string PersonID   = o["OrderPeople"]._ToStrTrim();
                string Poster     = o["Poster"]._ToStrTrim();
                string BKDH       = o["NewspaperName"]._ToStrTrim();
                string FullPrice  = o["FullPrice"]._ToStrTrim();
                string MoneyPayed = o["Pay"]._ToStrTrim();
                string test1      = o["test1"]._ToStrTrim();
                if (string.IsNullOrEmpty(ID))
                {
                    SqlHelp       dbhelper = new SqlHelp();
                    SqlConnection conn     = new SqlConnection(dbhelper.SqlConnectionString);
                    conn.Open();
                    using (SqlTransaction tran = conn.BeginTransaction())
                    {
                        try
                        {
                            ret = _BLL.Insert(tran, BKDH, PersonID._ToInt32(), OrderNum._ToInt32(), Month._ToInt32(),
                                              test1, userid._ToStr(), Poster._ToInt32(), FullPrice._ToDecimal());
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            ret.result = false;
                            ret.reason = ex.Message;
                            tran.Rollback();
                            throw;
                        }
                    }
                }
                else
                {
                    ret = _BLL.UpdateByPK(ID._ToInt32(), Month._ToInt32(), OrderNum._ToInt32(), BKDH,
                                          PersonID._ToInt32(), userid, Poster._ToInt32(), test1, NGUID);
                    if (ret.result)
                    {
                        CostBLL costBLL = new CostBLL();
                        costBLL.UpdateByPK(CostID._ToInt32(), FullPrice._ToDecimal(), MoneyPayed._ToDecimal(), userid);
                    }
                }
            }
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }