Пример #1
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(Nikita.Permission.Model.Bse_SetOrd model)
        {
            IMsSqlDataAccessService h      = ServiceHelper.GetMsSqlDataAccessService();
            StringBuilder           strSql = new StringBuilder();

            strSql.Append("update Bse_SetOrd set ");
            strSql.Append("SetOrd_Key=@SetOrd_Key, Name=@Name, PY=@PY, Sort=@Sort, Dept_Id=@Dept_Id, Company_Id=@Company_Id, Bloc_Id=@Bloc_Id, CreateName=@CreateName, CreateUserId=@CreateUserId, CreateDate=@CreateDate, Remark=@Remark, State=@State, SystemId=@SystemId  ");
            strSql.Append(" where SetOrd_Id=@SetOrd_Id ");

            h.CreateCommand(strSql.ToString());
            if (model.SetOrd_Id == null)
            {
                h.AddParameter("@SetOrd_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SetOrd_Id", model.SetOrd_Id);
            }
            if (model.SetOrd_Key == null)
            {
                h.AddParameter("@SetOrd_Key", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SetOrd_Key", model.SetOrd_Key);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.PY == null)
            {
                h.AddParameter("@PY", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PY", model.PY);
            }
            if (model.Sort == null)
            {
                h.AddParameter("@Sort", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Sort", model.Sort);
            }
            if (model.Dept_Id == null)
            {
                h.AddParameter("@Dept_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Dept_Id", model.Dept_Id);
            }
            if (model.Company_Id == null)
            {
                h.AddParameter("@Company_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Company_Id", model.Company_Id);
            }
            if (model.Bloc_Id == null)
            {
                h.AddParameter("@Bloc_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Bloc_Id", model.Bloc_Id);
            }
            if (model.CreateName == null)
            {
                h.AddParameter("@CreateName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateName", model.CreateName);
            }
            if (model.CreateUserId == null)
            {
                h.AddParameter("@CreateUserId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateUserId", model.CreateUserId);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.State == null)
            {
                h.AddParameter("@State", DBNull.Value);
            }
            else
            {
                h.AddParameter("@State", model.State);
            }
            if (model.SystemId == null)
            {
                h.AddParameter("@SystemId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SystemId", model.SystemId);
            }

            return(h.ExecuteNonQuery());
        }
Пример #2
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Permission.Model.Bse_SetOrd model)
        {
            IMsSqlDataAccessService h      = ServiceHelper.GetMsSqlDataAccessService();
            StringBuilder           strSql = new StringBuilder();

            strSql.Append("insert into Bse_SetOrd(");
            strSql.Append("SetOrd_Key, Name, PY, Sort, Dept_Id, Company_Id, Bloc_Id, CreateName, CreateUserId, CreateDate, Remark, State, SystemId  )");
            strSql.Append(" values (");
            strSql.Append("@SetOrd_Key, @Name, @PY, @Sort, @Dept_Id, @Company_Id, @Bloc_Id, @CreateName, @CreateUserId, @CreateDate, @Remark, @State, @SystemId  )");
            strSql.Append(";select @@IDENTITY");

            h.CreateCommand(strSql.ToString());
            if (model.SetOrd_Key == null)
            {
                h.AddParameter("@SetOrd_Key", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SetOrd_Key", model.SetOrd_Key);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.PY == null)
            {
                h.AddParameter("@PY", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PY", model.PY);
            }
            if (model.Sort == null)
            {
                h.AddParameter("@Sort", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Sort", model.Sort);
            }
            if (model.Dept_Id == null)
            {
                h.AddParameter("@Dept_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Dept_Id", model.Dept_Id);
            }
            if (model.Company_Id == null)
            {
                h.AddParameter("@Company_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Company_Id", model.Company_Id);
            }
            if (model.Bloc_Id == null)
            {
                h.AddParameter("@Bloc_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Bloc_Id", model.Bloc_Id);
            }
            if (model.CreateName == null)
            {
                h.AddParameter("@CreateName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateName", model.CreateName);
            }
            if (model.CreateUserId == null)
            {
                h.AddParameter("@CreateUserId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateUserId", model.CreateUserId);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.State == null)
            {
                h.AddParameter("@State", DBNull.Value);
            }
            else
            {
                h.AddParameter("@State", model.State);
            }
            if (model.SystemId == null)
            {
                h.AddParameter("@SystemId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SystemId", model.SystemId);
            }

            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }