public void UpdateEmployeeRole(SqlConnection connection, EmployeeRoleInfo _EmployeeRole) { using (var command = new SqlCommand("UPDATE tbl_EmployeeRoles \n" + "SET RoleName = @RoleName \n" + "WHERE (RoleID = @RoleID)", connection)) { AddSqlParameter(command, "@RoleID", _EmployeeRole.RoleID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@RoleName", _EmployeeRole.RoleName, System.Data.SqlDbType.NVarChar); WriteLogExecutingCommand(command); command.ExecuteScalar(); } }
public int InsertEmployeeRole(SqlConnection connection, EmployeeRoleInfo _EmployeeRole) { int lastestInserted = 0; using (var command = new SqlCommand("Insert into [dbo].[tbl_EmployeeRoles] ( RoleName)" + "VALUES( @RoleName) ", connection)) { //AddSqlParameter(command, "@RoleID", _EmployeeRole.RoleID, System.Data.SqlDbType.Int); AddSqlParameter(command, "@RoleName", _EmployeeRole.RoleName, System.Data.SqlDbType.NVarChar); WriteLogExecutingCommand(command); command.ExecuteScalar(); } return(lastestInserted); }
public ActionMessage Post([FromBody] EmployeeRoleInfo _employeeRole) { ActionMessage ret = new ActionMessage(); try { ret = EmployeeRoleServices.GetInstance().createEmployeeRole(_employeeRole); } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "001"; ret.err.msgString = ex.ToString(); } return(ret); }
public ActionMessage Put(int id, [FromBody] EmployeeRoleInfo _employeeRole) { ActionMessage ret = new ActionMessage(); try { EmployeeRoleServices.GetInstance().editEmployeeRole(id, _employeeRole); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "001"; ret.err.msgString = ex.ToString(); } return(ret); }
public List <EmployeeRoleInfo> GetAllEmployeeRole(SqlConnection connection) { var result = new List <EmployeeRoleInfo>(); using (var command = new SqlCommand("Select * from tbl_EmployeeRoles where 1 = 1 order by RoleID ", connection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { var info = new EmployeeRoleInfo(); info.RoleID = GetDbReaderValue <int>(reader["RoleID"]); info.RoleName = GetDbReaderValue <string>(reader["RoleName"]); result.Add(info); } } return(result); } }
public ActionMessage createEmployeeRole(EmployeeRoleInfo _employeeRole) { ActionMessage ret = new ActionMessage(); SqlConnectionFactory sqlConnection = new SqlConnectionFactory(); using (SqlConnection connection = sqlConnection.GetConnection()) { try { EmployeeRoleDataLayer.GetInstance().InsertEmployeeRole(connection, _employeeRole); ret.isSuccess = true; } catch (Exception ex) { ret.isSuccess = false; ret.err.msgCode = "Internal Error"; ret.err.msgString = ex.ToString(); } } return(ret); }