protected void gvOrders_RowDeleting(object sender, GridViewDeleteEventArgs e) { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); try { SvcKitchen.ServiceResult result = svc.DeleteOrder(int.Parse(gvOrders.Rows[e.RowIndex].Cells[2].Text)); if (result.ErrorCode == 0) { GetOrders(); lblInfo.ForeColor = System.Drawing.Color.DarkGreen; } else { lblInfo.ForeColor = System.Drawing.Color.DarkRed; } lblInfo.Text = result.Message; } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "There was an error attempting to delete the order."; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); GetRoleFromForm(isNew); result = svc.RoleSave(role); lblInfo.DisplayResult(result); pnlEdit.Visible = false; lblID.Text = ""; txtDescription.Text = ""; LoadData(); } catch { lblInfo.Text = "There was an error attempting to submit the role."; lblInfo.ForeColor = System.Drawing.Color.DarkRed; } }
protected void gvRoles_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); role = new SvcKitchen.Role(); role.ID = int.Parse(gvRoles.Rows[e.RowIndex].Cells[2].Text); role.Description = gvRoles.Rows[e.RowIndex].Cells[3].Text; result = svc.RoleDelete(role); lblInfo.DisplayResult(result); pnlEdit.Visible = false; lblID.Text = ""; txtDescription.Text = ""; LoadData(); } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "There was an error attempting to delete the role."; } }
protected void gvIngredients_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); result = svc.DeleteIngredient(int.Parse(gvIngredients.Rows[e.RowIndex].Cells[2].Text)); lblInfo.DisplayResult(result); pnlEdit.Visible = false; try { LoadIngredients(); } catch { lblInfo.Text = "There was an error attempting to load the Data."; lblInfo.ForeColor = System.Drawing.Color.DarkRed; } } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "There was an error attempting to delete the ingredient."; } }
protected void btnYes_Click(object sender, EventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); result = svc.DeleteUser(userDeleting.ID); if (result.ErrorCode == 0) { lblInfo.ForeColor = System.Drawing.Color.DarkGreen; } else { lblInfo.ForeColor = System.Drawing.Color.DarkRed; } lblInfo.Text = result.Message; LoadData(); } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "There was an error trying to delete the user."; } finally { pnlDelete.Visible = false; btnNo.Enabled = false; btnYes.Enabled = false; } }
protected void gvMealLines_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); // delete by meal line id result = svc.DeleteMealLine(int.Parse(gvMealLines.Rows[e.RowIndex].Cells[2].Text)); // set the colour of the label to red if there is an error, else green; and then display the result's message. lblLineInfo.DisplayResult(result); pnlEditMealLine.Visible = false; // reload the meal lines try { LoadMealLines(); } catch { lblLineInfo.Text = "There was an error attempting to load the Data."; lblLineInfo.ForeColor = System.Drawing.Color.DarkRed; } } catch { lblLineInfo.ForeColor = System.Drawing.Color.DarkRed; lblLineInfo.Text = "There was an error attempting to delete the meal/recipe."; } }
/// <summary> /// Loads the ingredients and displays them. /// </summary> private void LoadIngredients() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); gvIngredients.DataSource = svc.GetIngredients(out result); gvIngredients.DataBind(); lblInfo.DisplayResult(result); }
/// <summary> /// Load all of the data. /// </summary> private void LoadData() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); gvRoles.DataSource = svc.RoleGetAll(out result); gvRoles.DataBind(); lblInfo.DisplayResult(result); }
/// <summary> /// Loads the meal lines and displays them. /// </summary> private void LoadMealLines() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); gvMealLines.DataSource = svc.GetMealLines(meal.ID, out result); gvMealLines.DataBind(); lblLineInfo.DisplayResult(result); }
/// <summary> /// Fills gvRoles with all of the user roles. /// </summary> private void GetUserRoles() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); gvRoles.DataSource = svc.GetUserRolesById(userID, out result); gvRoles.DataBind(); lblInfo.Text = result.Message; }
/// <summary> /// Sets the label ForeColour to dark red if there is an error, dark green if there is no error. /// Sets the text to the result's message. /// </summary> /// <param name="lbl">Label to modify.</param> /// <param name="result">ServiceResult object.</param> public static void DisplayResult(this Label lbl, SvcKitchen.ServiceResult result) { if (result.ErrorCode == 0) { lbl.ForeColor = System.Drawing.Color.DarkGreen; } else { lbl.ForeColor = System.Drawing.Color.DarkRed; } lbl.Text = result.Message; }
/// <summary> /// Loads the meal lines and displays them. /// </summary> private void PopulateIngredients() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); cboIngredients.DataSource = svc.GetIngredients(out result); cboIngredients.DataValueField = "ID"; cboIngredients.DataTextField = "Name"; cboIngredients.DataBind(); lblLineInfo.DisplayResult(result); }
protected void gvRoles_SelectedIndexChanged(object sender, EventArgs e) { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); ur = new UserRole(); ur.UserRoleID = Convert.ToInt32(gvRoles.SelectedRow.Cells[1].Text); ur.UserID = Convert.ToInt32(gvRoles.SelectedRow.Cells[2].Text); ur.RoleID = Convert.ToInt32(gvRoles.SelectedRow.Cells[3].Text); ur.AccessLevel = Convert.ToInt32(gvRoles.SelectedRow.Cells[4].Text); ur.RoleName = gvRoles.SelectedRow.Cells[5].Text; DisplayUserRole(ur); lblRole.Enabled = true; txtAccessLevel.Enabled = true; btnSaveUserRole.Enabled = true; pnlUserRoles.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } switch (this.GetAccessLevel("Users")) { case AccessLevel.Deny: Response.Redirect("~/Users/Users.aspx"); break; case AccessLevel.Read: btnSaveUserCredentials.Enabled = false; btnSaveUserRole.Enabled = false; txtConfirm.Enabled = false; txtPassword.Enabled = false; txtUsername.Enabled = false; txtAccessLevel.Enabled = false; gvRoles.Enabled = false; break; } userID = (int)Session["UserID"]; SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); u = svc.GetUserByID(userID, out result); DisplayUser(); GetUserRoles(); lblInfo.Text = result.Message; lblRole.Enabled = false; txtAccessLevel.Enabled = false; btnSaveUserRole.Enabled = false; }
protected void btnSubmit_Click(object sender, EventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); GetIngredientFromForm(isNewIngredient); if (ingredient.ID == 0) { result = svc.AddIngredient(ingredient.Name); } else { result = svc.UpdateIngredient(ingredient.Name, ingredient.ID); } lblInfo.DisplayResult(result); pnlEdit.Visible = false; lblID.Text = ""; txtIngredientName.Text = ""; try { LoadIngredients(); } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "Looks like there was an error attempting to load the data."; } } catch { lblInfo.Text = "There was an error attempting to submit the ingredient."; lblInfo.ForeColor = System.Drawing.Color.DarkRed; } }
private void LoadData() { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); var users = svc.GetAllUsers(out result); DataTable dtUsers = new DataTable(); dtUsers.Columns.Add(); dtUsers.Columns.Add(); dtUsers.Columns.Add(); foreach (SvcKitchen.User u in users) { dtUsers.Rows.Add(new object[] { u.ID, u.Username, u.Password }); } if (result.ErrorCode == 0) { gvUsers.DataSource = users; gvUsers.DataBind(); for (int i = 0; i < users.Length; i++) { if ((string)dtUsers.Rows[i][2] == "password") { gvUsers.Rows[i].Cells[2].Text = "*" + gvUsers.Rows[i].Cells[2].Text; } } lblInfo.ForeColor = System.Drawing.Color.DarkGreen; lblInfo.Text = result.Message; } else { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = result.Message; } }
/// <summary> /// Delete the meal, and the meal lines that are related to the meal. /// </summary> protected void gvMeals_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); // Delete meal lines to prevent the meal lines from having no corresponding meal. result = svc.DeleteMealLineByMealID(int.Parse(gvMeals.Rows[e.RowIndex].Cells[2].Text)); // If there is no error deleting the meal lines, delete the meal. if (result.ErrorCode == 0) { result = svc.DeleteMeal(int.Parse(gvMeals.Rows[e.RowIndex].Cells[2].Text)); } // set the colour of the label to red if there is an error, else green; and then display the result's message. lblInfo.DisplayResult(result); pnlEdit.Visible = false; try { LoadMeals(); } catch { lblInfo.Text = "There was an error attempting to load the Data."; lblInfo.ForeColor = System.Drawing.Color.DarkRed; } } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "There was an error attempting to delete the meal/recipe."; } }
protected void btnSubmitLine_Click(object sender, EventArgs e) { try { SvcKitchen.SvcKitchenSoapClient svc = new SvcKitchen.SvcKitchenSoapClient(); SvcKitchen.ServiceResult result = new SvcKitchen.ServiceResult(); // get the meal line GetMealLineFromForm(isNewMealLine); // add/update it result = svc.AddMealLine(mealLine); lblLineInfo.DisplayResult(result); // reset the form pnlEditMealLine.Visible = false; ClearMealLineForm(); // reload try { LoadMealLines(); } catch { lblInfo.ForeColor = System.Drawing.Color.DarkRed; lblInfo.Text = "Looks like there was an error attempting to load the data."; } } catch { lblInfo.Text = "There was an error attempting to submit the recipe."; lblInfo.ForeColor = System.Drawing.Color.DarkRed; } }