protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int    id   = Convert.ToInt32(e.CommandArgument);
            string name = e.CommandName.ToString();

            if (name == "update")
            {
                int value = 0;
                HtmlInputRadioButton valueInt = (HtmlInputRadioButton)e.Item.FindControl("ropen");
                if (valueInt.Checked == true)
                {
                    value = 1;
                }

                lgk.Model.gp_globeParam item_param = gpBLL.GetModel(id);
                if (item_param != null)
                {
                    item_param.ParamInt = value;
                    if (gpBLL.Update(item_param))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改成功!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改失败!');", true);
                    }
                }
                bindrdo();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.gp_globeParam GetModel(long Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, ParamName, ParamAmount, ParamInt, ParamVarchar, Remark, ParamType, EndRemark, IsEdit  ");
            strSql.Append("  from gp_globeParam ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.BigInt)
            };
            parameters[0].Value = Id;

            lgk.Model.gp_globeParam model = new lgk.Model.gp_globeParam();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = long.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.ParamName = ds.Tables[0].Rows[0]["ParamName"].ToString();
                if (ds.Tables[0].Rows[0]["ParamAmount"].ToString() != "")
                {
                    model.ParamAmount = decimal.Parse(ds.Tables[0].Rows[0]["ParamAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParamInt"].ToString() != "")
                {
                    model.ParamInt = int.Parse(ds.Tables[0].Rows[0]["ParamInt"].ToString());
                }
                model.ParamVarchar = ds.Tables[0].Rows[0]["ParamVarchar"].ToString();
                model.Remark       = ds.Tables[0].Rows[0]["Remark"].ToString();
                if (ds.Tables[0].Rows[0]["ParamType"].ToString() != "")
                {
                    model.ParamType = int.Parse(ds.Tables[0].Rows[0]["ParamType"].ToString());
                }
                model.EndRemark = ds.Tables[0].Rows[0]["EndRemark"].ToString();
                if (ds.Tables[0].Rows[0]["IsEdit"].ToString() != "")
                {
                    model.IsEdit = int.Parse(ds.Tables[0].Rows[0]["IsEdit"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.gp_globeParam model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update gp_globeParam set ");

            strSql.Append(" ParamName = @ParamName , ");
            strSql.Append(" ParamAmount = @ParamAmount , ");
            strSql.Append(" ParamInt = @ParamInt , ");
            strSql.Append(" ParamVarchar = @ParamVarchar , ");
            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" ParamType = @ParamType , ");
            strSql.Append(" EndRemark = @EndRemark , ");
            strSql.Append(" IsEdit = @IsEdit  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",           SqlDbType.BigInt,   8),
                new SqlParameter("@ParamName",    SqlDbType.VarChar, 50),
                new SqlParameter("@ParamAmount",  SqlDbType.Decimal,  9),
                new SqlParameter("@ParamInt",     SqlDbType.Int,      4),
                new SqlParameter("@ParamVarchar", SqlDbType.VarChar, 50),
                new SqlParameter("@Remark",       SqlDbType.VarChar, -1),
                new SqlParameter("@ParamType",    SqlDbType.Int,      4),
                new SqlParameter("@EndRemark",    SqlDbType.VarChar, -1),
                new SqlParameter("@IsEdit",       SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.ParamName;
            parameters[2].Value = model.ParamAmount;
            parameters[3].Value = model.ParamInt;
            parameters[4].Value = model.ParamVarchar;
            parameters[5].Value = model.Remark;
            parameters[6].Value = model.ParamType;
            parameters[7].Value = model.EndRemark;
            parameters[8].Value = model.IsEdit;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.gp_globeParam GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, ParamName, ParamAmount, ParamInt, ParamVarchar, Remark, ParamType, EndRemark, IsEdit  ");
            strSql.Append(" from gp_globeParam ");
            if (strWhere.Trim() == "")
            {
                strSql.Append(" where " + strWhere);
            }

            lgk.Model.gp_globeParam model = new lgk.Model.gp_globeParam();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = long.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.ParamName = ds.Tables[0].Rows[0]["ParamName"].ToString();
                if (ds.Tables[0].Rows[0]["ParamAmount"].ToString() != "")
                {
                    model.ParamAmount = decimal.Parse(ds.Tables[0].Rows[0]["ParamAmount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParamInt"].ToString() != "")
                {
                    model.ParamInt = int.Parse(ds.Tables[0].Rows[0]["ParamInt"].ToString());
                }
                model.ParamVarchar = ds.Tables[0].Rows[0]["ParamVarchar"].ToString();
                model.Remark       = ds.Tables[0].Rows[0]["Remark"].ToString();
                if (ds.Tables[0].Rows[0]["ParamType"].ToString() != "")
                {
                    model.ParamType = int.Parse(ds.Tables[0].Rows[0]["ParamType"].ToString());
                }
                model.EndRemark = ds.Tables[0].Rows[0]["EndRemark"].ToString();
                if (ds.Tables[0].Rows[0]["IsEdit"].ToString() != "")
                {
                    model.IsEdit = int.Parse(ds.Tables[0].Rows[0]["IsEdit"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.gp_globeParam model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into gp_globeParam(");
            strSql.Append("ParamName,ParamAmount,ParamInt,ParamVarchar,Remark,ParamType,EndRemark,IsEdit");
            strSql.Append(") values (");
            strSql.Append("@ParamName,@ParamAmount,@ParamInt,@ParamVarchar,@Remark,@ParamType,@EndRemark,@IsEdit");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParamName",    SqlDbType.VarChar, 50),
                new SqlParameter("@ParamAmount",  SqlDbType.Decimal,  9),
                new SqlParameter("@ParamInt",     SqlDbType.Int,      4),
                new SqlParameter("@ParamVarchar", SqlDbType.VarChar, 50),
                new SqlParameter("@Remark",       SqlDbType.VarChar, -1),
                new SqlParameter("@ParamType",    SqlDbType.Int,      4),
                new SqlParameter("@EndRemark",    SqlDbType.VarChar, -1),
                new SqlParameter("@IsEdit",       SqlDbType.Int, 4)
            };

            parameters[0].Value = model.ParamName;
            parameters[1].Value = model.ParamAmount;
            parameters[2].Value = model.ParamInt;
            parameters[3].Value = model.ParamVarchar;
            parameters[4].Value = model.Remark;
            parameters[5].Value = model.ParamType;
            parameters[6].Value = model.EndRemark;
            parameters[7].Value = model.IsEdit;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Esempio n. 6
0
        private bool UpdateParam(int id, HtmlInputText valuemoney, out string msg)
        {
            decimal value = 0;

            lgk.Model.gp_globeParam paramInfo = gpBLL.GetModel(id);

            if (paramInfo != null)
            {
                string strRemark = paramInfo.Remark.Replace("</font>", "").Replace("<font color=\"red\">", "").Replace("&gt;", ">");
                msg = "更新完成[" + strRemark + "]\\n";
                if (valuemoney.Value == "")
                {
                    msg = "请输入参数值[" + strRemark + "]\\n"; return(false);
                }

                if (paramInfo.ParamType == 1)//Decimal
                {
                    try
                    {
                        value = Convert.ToDecimal(valuemoney.Value);
                    }
                    catch
                    {
                        msg = "参数格式错误[" + strRemark + "]\\n"; return(false);
                    }
                    if (value < 0)
                    {
                        msg = "请输入大于等于0的参数[" + strRemark + "]\\n"; return(false);
                    }
                }
                else if (paramInfo.ParamType == 2)//Int
                {
                    try
                    {
                        value = Convert.ToInt32(valuemoney.Value);
                    }
                    catch
                    {
                        msg = "请输入整数[" + strRemark + "]\\n"; return(false);
                    }
                }
                else if (paramInfo.ParamType == 3)//Decimal
                {
                    value = Convert.ToDecimal(valuemoney.Value);

                    if (value > 100)
                    {
                        msg = "比率不能大于100%的参数[" + strRemark + "]\\n"; return(false);
                    }
                }

                if (paramInfo.ParamType <= 3)
                {
                    paramInfo.ParamVarchar = value.ToString();
                }
                else if (paramInfo.ParamType == 4)
                {
                    paramInfo.ParamVarchar = valuemoney.Value;
                }
                //paramInfo.ParamVarchar = paramInfo.ParamType == 1 ? valuemoney.Value : value.ToString();

                if (!gpBLL.Update(paramInfo))
                {
                    msg = "更新出错[" + strRemark + "]\\n";
                }
                return(false);
            }
            else
            {
                msg = "数据不存在,无法更新!";
            }

            return(true);
        }
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int    id   = Convert.ToInt32(e.CommandArgument);
            string name = e.CommandName.ToString();

            if (name == "update")
            {
                decimal       value      = 0;
                HtmlInputText valuemoney = (HtmlInputText)e.Item.FindControl("paramValue");
                if (valuemoney.Value == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入参数值!');", true);
                    return;
                }
                try
                {
                    value = Convert.ToDecimal(valuemoney.Value);
                }
                catch (Exception)
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入数字格式参数!');", true);
                    return;
                }
                if (value <= 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入大于0的参数!');", true);
                    return;
                }

                lgk.Model.gp_globeParam item_param = gpBLL.GetModel(id);
                if (item_param != null)
                {
                    if (item_param.ParamType == 1)
                    {
                        if (value > 100)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('比率不能大于100%!');", true);
                            return;
                        }
                    }
                    item_param.ParamAmount = value;
                    if (item_param.ParamName == "gp_rate")
                    {
                        DbHelperSQL.Query("update gp_globeParam set ParamAmount=" + (100 - value) + " where ParamName='hg_rate'");
                    }
                    if (item_param.ParamName == "hg_rate")
                    {
                        DbHelperSQL.Query("update gp_globeParam set ParamAmount=" + (100 - value) + " where ParamName='gp_rate'");
                    }
                    if (gpBLL.Update(item_param))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改成功!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改失败!');", true);
                    }
                }
                bind();
            }
        }