Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static EtNet_Models.ModuleCodingInfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from ModuleCodingInfo ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            EtNet_Models.ModuleCodingInfo model = new EtNet_Models.ModuleCodingInfo();
            DataTable tbl = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters);

            if (tbl.Rows.Count > 0)
            {
                model.id         = int.Parse(tbl.Rows[0]["id"].ToString());
                model.num        = tbl.Rows[0]["num"].ToString();
                model.cname      = tbl.Rows[0]["cname"].ToString();
                model.txtformat  = tbl.Rows[0]["txtformat"].ToString();
                model.orderlen   = int.Parse(tbl.Rows[0]["orderlen"].ToString());
                model.usecode    = int.Parse(tbl.Rows[0]["usecode"].ToString());
                model.usetxt     = tbl.Rows[0]["usetxt"].ToString();
                model.createtime = DateTime.Parse(tbl.Rows[0]["createtime"].ToString());
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        protected void rptdata_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int      id  = int.Parse(e.CommandArgument.ToString());
            CheckBox box = null;
            TextBox  tbx = null;

            EtNet_Models.ModuleCodingInfo model = EtNet_BLL.ModuleCodingInfoManager.GetModel(id);
            if (model != null)
            {
                box = e.Item.Controls[1] as CheckBox;
                if (box != null)
                {
                    if (box.Checked)
                    {
                        model.usecode = 1;
                        model.usetxt  = "启用";
                    }
                    else
                    {
                        model.usecode = 0;
                        model.usetxt  = "禁用";
                    }
                }

                tbx = e.Item.Controls[3] as TextBox;
                if (tbx != null)
                {
                    model.txtformat = tbx.Text;
                    if (model.usecode == 1 && model.txtformat == "")
                    {
                        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "edit", "<script>alert('编辑失败,表达式不能为空!')</script>", false);
                        return;
                    }
                }

                tbx = e.Item.Controls[5] as TextBox;
                if (tbx != null)
                {
                    model.orderlen = int.Parse(tbx.Text);
                }
                model.createtime = DateTime.Now;
                if (EtNet_BLL.ModuleCodingInfoManager.Update(model))
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "edit", "<script>alert('编辑成功!')</script>", false);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "edit", "<script>alert('编辑失败!')</script>", false);
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "edit", "<script>alert('编辑失败!')</script>", false);
                LoadModuleCodingData();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(EtNet_Models.ModuleCodingInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ModuleCodingInfo set ");
            strSql.Append("num=@num,");
            strSql.Append("cname=@cname,");
            strSql.Append("txtformat=@txtformat,");
            strSql.Append("orderlen=@orderlen,");
            strSql.Append("usecode=@usecode,");
            strSql.Append("usetxt=@usetxt,");
            strSql.Append("createtime=@createtime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@num",        SqlDbType.VarChar,    10),
                new SqlParameter("@cname",      SqlDbType.VarChar,    40),
                new SqlParameter("@txtformat",  SqlDbType.VarChar,   100),
                new SqlParameter("@orderlen",   SqlDbType.Int,         4),
                new SqlParameter("@usecode",    SqlDbType.Int,         4),
                new SqlParameter("@usetxt",     SqlDbType.VarChar,     4),
                new SqlParameter("@createtime", SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.num;
            parameters[1].Value = model.cname;
            parameters[2].Value = model.txtformat;
            parameters[3].Value = model.orderlen;
            parameters[4].Value = model.usecode;
            parameters[5].Value = model.usetxt;
            parameters[6].Value = model.createtime;
            parameters[7].Value = model.id;

            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(EtNet_Models.ModuleCodingInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ModuleCodingInfo(");
            strSql.Append("num,cname,txtformat,orderlen,usecode,usetxt,createtime)");
            strSql.Append(" values (");
            strSql.Append("@num,@cname,@txtformat,@orderlen,@usecode,@usetxt,@createtime)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@num",        SqlDbType.VarChar,  10),
                new SqlParameter("@cname",      SqlDbType.VarChar,  40),
                new SqlParameter("@txtformat",  SqlDbType.VarChar, 100),
                new SqlParameter("@orderlen",   SqlDbType.Int,       4),
                new SqlParameter("@usecode",    SqlDbType.Int,       4),
                new SqlParameter("@usetxt",     SqlDbType.VarChar,   4),
                new SqlParameter("@createtime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.num;
            parameters[1].Value = model.cname;
            parameters[2].Value = model.txtformat;
            parameters[3].Value = model.orderlen;
            parameters[4].Value = model.usecode;
            parameters[5].Value = model.usetxt;
            parameters[6].Value = model.createtime;

            int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static bool Update(EtNet_Models.ModuleCodingInfo model)
 {
     return(EtNet_DAL.ModuleCodingInfoService.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static bool Add(EtNet_Models.ModuleCodingInfo model)
 {
     return(EtNet_DAL.ModuleCodingInfoService.Add(model));
 }