Esempio n. 1
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.account_manager   bll   = new BLL.account_manager();
                Model.account_manager model = bll.GetModel(_id);

                int parentId = int.Parse(ddlParentId.SelectedValue);
                model.name = txtName.Text.Trim();
                //如果选择的父ID不是自己,则更改
                if (parentId != model.id)
                {
                    model.parent_id = parentId;
                }
                model.sort_id = int.Parse(txtSortId.Text.Trim());
                if (bll.Update(model))
                {
                    AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改科目分类:" + model.name); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.account_manager model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into account_manager(");
            strSql.Append("parent_id,name,type,sort_id)");
            strSql.Append(" values (");
            strSql.Append("@parent_id,@name,@type,@sort_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@parent_id", SqlDbType.Int,       4),
                new SqlParameter("@name",      SqlDbType.NVarChar, 50),
                new SqlParameter("@type",      SqlDbType.NVarChar, 50),
                new SqlParameter("@sort_id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.parent_id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.sort_id;

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

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

            strSql.Append("update account_manager set ");
            strSql.Append("parent_id=@parent_id,");
            strSql.Append("name=@name,");
            strSql.Append("type=@type,");
            strSql.Append("sort_id=@sort_id");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@parent_id", SqlDbType.Int,       4),
                new SqlParameter("@name",      SqlDbType.NVarChar, 50),
                new SqlParameter("@type",      SqlDbType.NVarChar, 50),
                new SqlParameter("@sort_id",   SqlDbType.Int,       4),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.parent_id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.sort_id;
            parameters[4].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 组合成对象实体
 /// </summary>
 private Model.account_manager DataRowToModel(DataRow row)
 {
     Model.account_manager model = new Model.account_manager();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
     }
     return(model);
 }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体,带事务
        /// </summary>
        public Model.account_manager GetModel(SqlConnection conn, SqlTransaction trans, string nav_name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 *");
            strSql.Append(" from account_manager ");
            strSql.Append(" where name=@nav_name");
            SqlParameter[] parameters =
            {
                new SqlParameter("@nav_name", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = nav_name;

            Model.account_manager model = new Model.account_manager();
            DataSet ds = DbHelperSQL.Query(conn, trans, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.account_manager GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        private void ShowInfo(int _id)
        {
            BLL.account_manager   bll   = new BLL.account_manager();
            Model.account_manager model = bll.GetModel(_id);

            ddlParentId.SelectedValue = model.parent_id.ToString();
            txtName.Text   = model.name;
            txtSortId.Text = model.sort_id.ToString();
        }
Esempio n. 8
0
 private bool DoAdd()
 {
     try
     {
         Model.account_manager model = new Model.account_manager();
         BLL.account_manager   bll   = new BLL.account_manager();
         model.name      = txtName.Text.Trim();
         model.parent_id = int.Parse(ddlParentId.SelectedValue);
         model.sort_id   = int.Parse(txtSortId.Text.Trim());
         if (bll.Add(model) > 0)
         {
             AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加科目分类:" + model.name); //记录日志
             return(true);
         }
     }
     catch
     {
         return(false);
     }
     return(false);
 }
Esempio n. 9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.account_manager model)
 {
     return(dal.Update(model));
 }
Esempio n. 10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.account_manager model)
 {
     return(dal.Add(model));
 }