示例#1
0
        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();
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
        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);
        }