Esempio n. 1
0
        /// <summary>
        /// 修改信息
        /// </summary>
        /// <param name="_DepartmentLeaderEntity"></param>
        /// <returns>返回string "-1"表示该已经存在,否则成功 </returns>
        public string UpdateDepartmentLeader(DepartmentLeaderEntity _DepartmentLeaderEntity)
        {
            //判断该记录是否已经存在
            DbParameter[] prams = {
                                      MakeInParam("@DeptID",(DbType)SqlDbType.Int,4,_DepartmentLeaderEntity.DeptID),
                                  };
            string sql = "select * from DepartmentLeader where DeptID=@DeptID ";
            if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0)
            {
                DbParameter[] pramsUpdate = {
                                       MakeInParam("@DeptID",(DbType)SqlDbType.Int,4,_DepartmentLeaderEntity.DeptID ),
                                       MakeInParam("@UserSerialID",(DbType)SqlDbType.Int,4,_DepartmentLeaderEntity.UserSerialID ),
                                       MakeInParam("@lastModifier",(DbType)SqlDbType.VarChar,50,_DepartmentLeaderEntity.lastModifier ),
                                       MakeInParam("@lastModifyDate",(DbType)SqlDbType.DateTime,23,_DepartmentLeaderEntity.lastModifyDate ),
                                             };

                StringBuilder sb = new StringBuilder();
                sb.Append("Update [dbo].[DepartmentLeader]");
                sb.Append(" set ");
                sb.Append(" [UserSerialID]=@UserSerialID,");
                sb.Append(" [lastModifier]=@lastModifier,");
                sb.Append(" [lastModifyDate]=@lastModifyDate ");
                sb.Append(" where [DeptID]=@DeptID");
                return ExecuteNonQuery(CommandType.Text, sb.ToString(), pramsUpdate).ToString();
            }
            else
            {
                DbParameter[] pramsInsert = {
                                       MakeInParam("@DeptID",(DbType)SqlDbType.Int,4,_DepartmentLeaderEntity.DeptID ),
                                       MakeInParam("@UserSerialID",(DbType)SqlDbType.Int,4,_DepartmentLeaderEntity.UserSerialID ),
                                       MakeInParam("@lastModifier",(DbType)SqlDbType.VarChar,50,_DepartmentLeaderEntity.lastModifier ),
                                       MakeInParam("@lastModifyDate",(DbType)SqlDbType.DateTime,23,_DepartmentLeaderEntity.lastModifyDate ),
                                             };
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].[DepartmentLeader]");
                sb.Append("(");
                sb.Append(" [DeptID]");
                sb.Append(",[UserSerialID]");
                sb.Append(",[lastModifier]");
                sb.Append(",[lastModifyDate]");
                sb.Append(") ");
                sb.Append(" VALUES (");
                sb.Append("@DeptID,");
                sb.Append("@UserSerialID,");
                sb.Append("@lastModifier,");
                sb.Append("@lastModifyDate )");
                sb.Append("select @@identity;");
                return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
            }
        }
Esempio n. 2
0
        private string SaveData()
        {
            DepartmentLeaderEntity _DepartmentLeaderEntity = new DepartmentLeaderEntity();
            _DepartmentLeaderEntity.DeptID = Convert.ToInt32(txtDeptID.Value);
            _DepartmentLeaderEntity.UserSerialID = Convert.ToInt32(txtUserSerialID.Value);
            _DepartmentLeaderEntity.lastModifier = userEntity.UserID;
            _DepartmentLeaderEntity.lastModifyDate = DateTime.Now;

            string sResult = DbHelper.GetInstance().UpdateDepartmentLeader(_DepartmentLeaderEntity);
            return sResult;
        }