Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.jmp_poundage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into jmp_poundage(");
            strSql.Append("p_sprice,p_eprice,p_rate,p_state");
            strSql.Append(") values (");
            strSql.Append("@p_sprice,@p_eprice,@p_rate,@p_state");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@p_sprice", SqlDbType.Int,     4),
                new SqlParameter("@p_eprice", SqlDbType.Int,     4),
                new SqlParameter("@p_rate",   SqlDbType.Decimal, 5),
                new SqlParameter("@p_state",  SqlDbType.Int, 4)
            };

            parameters[0].Value = model.p_sprice;
            parameters[1].Value = model.p_eprice;
            parameters[2].Value = model.p_rate;
            parameters[3].Value = model.p_state;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加或修改结算界面
        /// </summary>
        /// <returns></returns>
        public ActionResult SettlementAddOrUpdate()
        {
            int p_id = string.IsNullOrEmpty(Request["p_id"]) ? 0 : Int32.Parse(Request["p_id"]);

            JMP.BLL.jmp_poundage bll  = new JMP.BLL.jmp_poundage();
            JMP.MDL.jmp_poundage mode = new JMP.MDL.jmp_poundage();
            if (p_id > 0)
            {
                mode = bll.GetModel(p_id);
            }
            ViewBag.mode = mode;
            return(View());
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_poundage GetModel(int p_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select p_id, p_sprice, p_eprice, p_rate, p_state  ");
            strSql.Append("  from jmp_poundage ");
            strSql.Append(" where p_id=@p_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@p_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = p_id;


            JMP.MDL.jmp_poundage model = new JMP.MDL.jmp_poundage();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["p_id"].ToString() != "")
                {
                    model.p_id = int.Parse(ds.Tables[0].Rows[0]["p_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_sprice"].ToString() != "")
                {
                    model.p_sprice = int.Parse(ds.Tables[0].Rows[0]["p_sprice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_eprice"].ToString() != "")
                {
                    model.p_eprice = int.Parse(ds.Tables[0].Rows[0]["p_eprice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_rate"].ToString() != "")
                {
                    model.p_rate = decimal.Parse(ds.Tables[0].Rows[0]["p_rate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["p_state"].ToString() != "")
                {
                    model.p_state = int.Parse(ds.Tables[0].Rows[0]["p_state"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 添加或修改结算设置
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public JsonResult AddOrUpdateSettlement(JMP.MDL.jmp_poundage mode)
        {
            object retJson = new { success = 0, msg = "操作失败" };

            JMP.BLL.jmp_poundage bll = new JMP.BLL.jmp_poundage();
            if (mode.p_id > 0)
            {
                #region 修改
                JMP.MDL.jmp_poundage mo = bll.GetModel(mode.p_id);
                mode.p_state = mo.p_state;
                if (bll.Update(mode))
                {
                    #region 日志说明
                    Logger.ModifyLog("修改结算设置", mo, mode);
                    #endregion
                    retJson = new { success = 1, msg = "修改成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "修改失败" };
                }
                #endregion
            }
            else
            {
                #region 添加
                mode.p_state = 0;
                int cg = bll.Add(mode);
                if (cg > 0)
                {
                    Logger.CreateLog("添加结算设置", mode);
                    retJson = new { success = 1, msg = "添加成功" };
                }
                else
                {
                    retJson = new { success = 0, msg = "添加失败" };
                }
                #endregion
            }
            return(Json(retJson));
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_poundage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_poundage set ");

            strSql.Append(" p_sprice = @p_sprice , ");
            strSql.Append(" p_eprice = @p_eprice , ");
            strSql.Append(" p_rate = @p_rate , ");
            strSql.Append(" p_state = @p_state  ");
            strSql.Append(" where p_id=@p_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@p_id",     SqlDbType.Int,     4),
                new SqlParameter("@p_sprice", SqlDbType.Int,     4),
                new SqlParameter("@p_eprice", SqlDbType.Int,     4),
                new SqlParameter("@p_rate",   SqlDbType.Decimal, 5),
                new SqlParameter("@p_state",  SqlDbType.Int, 4)
            };

            parameters[0].Value = model.p_id;
            parameters[1].Value = model.p_sprice;
            parameters[2].Value = model.p_eprice;
            parameters[3].Value = model.p_rate;
            parameters[4].Value = model.p_state;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }