/// <summary> /// 修改员工 /// </summary> /// <param name="employee"> /// 员工对象 /// </param> public void ModifyEmployee(System_Employee employee) { this.systemEmployeeDA.Update(employee); }
/// <summary> /// 添加员工 /// </summary> /// <param name="employee"> /// 员工对象 /// </param> /// <returns> /// 主键编号 /// </returns> public int Insert(System_Employee employee) { if (employee == null) { throw new ArgumentNullException("employee"); } int id; var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "DepartmentID", SqlDbType.Int, employee.DepartmentID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CountyID", SqlDbType.Int, employee.CountyID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IdentityCard", SqlDbType.VarChar, employee.IdentityCard, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IdentityCardAddress", SqlDbType.NVarChar, employee.IdentityCardAddress, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "BankCard", SqlDbType.VarChar, employee.BankCard ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Name", SqlDbType.NVarChar, employee.Name, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Age", SqlDbType.Int, employee.Age, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Gender", SqlDbType.NVarChar, employee.Gender, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Mobile", SqlDbType.VarChar, employee.Mobile, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "HomeAddress", SqlDbType.NVarChar, employee.HomeAddress, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Status", SqlDbType.Int, employee.Status, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CreateTime", SqlDbType.DateTime, employee.CreateTime, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "ReferenceID", SqlDbType.Int, null, ParameterDirection.Output) }; try { this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Employee_Insert", parameters, null); id = (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value; } catch (Exception exception) { throw new Exception("Exception - SystemEmployeeDA - Insert", exception); } return id; }
/// <summary> /// 添加员工 /// </summary> /// <param name="employee"> /// 员工对象 /// </param> /// <returns> /// 员工编号 /// </returns> public int AddEmployee(System_Employee employee) { return this.systemEmployeeDA.Insert(employee); }
/// <summary> /// 修改员工 /// </summary> /// <param name="employee"> /// 员工对象 /// </param> public void Update(System_Employee employee) { if (employee == null) { throw new ArgumentNullException("employee"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ID", SqlDbType.Int, employee.ID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "DepartmentID", SqlDbType.Int, employee.DepartmentID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CountyID", SqlDbType.Int, employee.CountyID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IdentityCard", SqlDbType.VarChar, employee.IdentityCard, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IdentityCardAddress", SqlDbType.NVarChar, employee.IdentityCardAddress, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "BankCard", SqlDbType.VarChar, employee.BankCard ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Name", SqlDbType.NVarChar, employee.Name, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Age", SqlDbType.Int, employee.Age, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Gender", SqlDbType.NVarChar, employee.Gender, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Mobile", SqlDbType.VarChar, employee.Mobile, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "HomeAddress", SqlDbType.NVarChar, employee.HomeAddress, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Status", SqlDbType.Int, employee.Status, ParameterDirection.Input) }; try { this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Employee_Update", parameters, null); } catch (Exception exception) { throw new Exception("Exception - SystemEmployeeDA - Update", exception); } }