protected User CreateUser() { User user = new User(); Role role = new Role(); try { //User user.Name = textboxName.Value; user.LastName = textboxLastName.Value; user.Username = textboxUsernameR.Value; user.Password = textboxPasswordR.Value; if (hiddenConditionValue.Value.Equals(string.Empty)) { role.Id = Convert.ToInt32(selectCondition.Items[0].Value); role.Name = selectCondition.Items[0].Text; } else { role.Id = Convert.ToInt32(hiddenConditionValue.Value); role.Name = selectCondition.Items.FindByValue(hiddenConditionValue.Value).Text; } user.Role = role; user.UniversityCard = Convert.ToInt32(textboxUniversityCard.Value); return user; } catch (FormatException) { buttonStyle.buttonStyleRed(buttonErrors, "Invalid data, please check it or contact with us."); return null; } }
public void InsertRole(Role role) { connection = ManageDatabaseConnection("Open"); using (SqlCommand insert = new SqlCommand(@"InsertRole", connection)) { insert.CommandType = CommandType.StoredProcedure; insert.Parameters.Add("@Name", SqlDbType.VarChar).Value = role.Name; insert.ExecuteNonQuery(); } connection = ManageDatabaseConnection("Close"); }
public void UpdateRole(Role role) { connection = ManageDatabaseConnection("Open"); using (SqlCommand update = new SqlCommand(@"UpdateRole", connection)) { update.CommandType = CommandType.StoredProcedure; update.Parameters.Add("@Id", SqlDbType.Int).Value = role.Id; update.Parameters.Add("@Name", SqlDbType.VarChar).Value = role.Name; update.ExecuteNonQuery(); } connection = ManageDatabaseConnection("Close"); }
public User sendUser(DataTable dataTableUserInfo) { User user = new User(); Role role = new Role(); user.Name = dataTableUserInfo.Rows[0]["Name"].ToString(); user.LastName = dataTableUserInfo.Rows[0]["LastName"].ToString(); user.Username = dataTableUserInfo.Rows[0]["UserName"].ToString(); user.Password = dataTableUserInfo.Rows[0]["Password"].ToString(); role.Id = Convert.ToInt32(dataTableUserInfo.Rows[0]["RoleId"]); user.Role = role; user.UniversityCard = Convert.ToInt32(dataTableUserInfo.Rows[0]["UniversityCard"]); return user; }
protected Role CreateRole() { try { Role role = new Role(); role.Name = textboxRole.Value; return role; } catch (FormatException) { buttonStyle.buttonStyleWhite(buttonErrors, "Invalid data, please check it or contact with us."); return null; } }
public int UpdateRole(Role role) { try { if (role.Name.Equals(string.Empty)) { return 1; } else { roleData.UpdateRole(role); return 0; } } catch (SqlException) { return 2; } }
protected User CreateUser() { User user = new User(); Role role = new Role(); try { //Creating user user.Name = textboxName.Value; user.LastName = textboxLastName.Value; user.Username = textboxUsername.Value; user.Password = textboxPasswordShowed.Value; role.Id = Convert.ToInt32(Session["User-ConditionId"]); user.Role = role; user.UniversityCard = Convert.ToInt32(textboxUniversityCard.Value); return user; } catch { buttonStyle.buttonStyleRed(buttonErrors, "An error ocurred validating your new data, please check it."); return null; } }
protected void UpdateRole(Role role) { if (role != null) { switch (roleRules.UpdateRole(role)) { case 0: textboxRole.Value = ""; buttonStyle.buttonStyleBlue(buttonErrors, "Role updated successful."); break; case 1: buttonStyle.buttonStyleWhite(buttonErrors, "Role name field is empty."); break; case 2: buttonStyle.buttonStyleRed(buttonErrors, "An error ocurred updating the role, please check data or contact we us."); break; } } }