public static void RequestAccess(Admin requestingAdmin, Company customer ,Company supplier ) { // create mail message object MailMessage mail = new MailMessage(); mail.From = new MailAddress(sender); // put the from address here mail.To.Add(new MailAddress(supplier.contact_email)); // put to address here mail.Subject = "New Request from a retailer in Healthstop"; // put subject here string serverPath = HttpContext.Current.Server.MapPath("/email/"); string body = File.ReadAllText(serverPath + "RequestAccessEmail.txt"); body = body.Replace("$fullName", requestingAdmin.full_name); body = body.Replace("$store", customer.name); body = body.Replace("$abn", customer.company_number); body = body.Replace("$email", customer.contact_email); body = body.Replace("$phone", customer.phone); mail.Body = body; SmtpClient client = new SmtpClient(); try { client.Send(mail); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); if (!IsPostBack) { PopulateSuppliers(); } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); requestedCompany = Helpers.GetRequestedCompany(); homeCompany = Helpers.GetCurrentCompany(); if (homeCompany.is_customer && requestedCompany.is_customer) { Response.Redirect("/status.aspx?errormessage=notallowed"); } if (homeCompany.AllowedStoresBysupplier_.Where(p => p.supplier_id == requestedCompany.company_id).Count() == 0) { SupplierPanel.Visible = true; SupplierPanel.Enabled = true; AccessAvailableLabel.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); if (!(Helpers.IsAuthorizedAdmin(loggedInAdmin, homeCompany))) { Response.Redirect("/status.aspx?error=notadmin"); } else if (!homeCompany.is_customer) { Response.Redirect("/status.aspx?error=notcustomer"); } if (!IsPostBack) { InvoicesGridView.DataSource = Invoice.GetInvoicesByCustomer(homeCompany.company_id); InvoicesGridView.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); currentInvoice = Helpers.GetRequestedInvoice(); permission = AllowedStore.GetAllowedStoreByCustomerSupplier(homeCompany.company_id, currentInvoice.supplier_id); if (!(Helpers.IsAuthorizedAdmin(loggedInAdmin, homeCompany))) { Response.Redirect("/status.aspx?error=notadmin"); } else if (!(currentInvoice.customer_id == homeCompany.company_id || currentInvoice.supplier_id == homeCompany.company_id)) { Response.Redirect("/status.aspx?error=genericerror"); } if (!IsPostBack) { PopulateDetails(); PopulateInvoiceItems(); } }
protected void Page_Load(object sender, EventArgs e) { loggedInAdmin = Helpers.GetLoggedInAdmin(); homeCompany = Helpers.GetCurrentCompany(); currentOrder = Helpers.GetRequestedPurchaseOrder(); permission = AllowedStore.GetAllowedStoreByCustomerSupplier(homeCompany.company_id, currentOrder.supplier_id); if (!(Helpers.IsAuthorizedAdmin(loggedInAdmin, homeCompany))) { Response.Redirect("/status.aspx?error=notadmin"); } else if (!(currentOrder.customer_id == homeCompany.company_id || currentOrder.supplier_id == homeCompany.company_id)) { Response.Redirect("/status.aspx?error=genericerror"); } if (!IsPostBack) { PopulateDetails(); PopulateOrderItems(); PopulaterInvoices(); } if (currentOrder.is_submitted) { StatusLabel.Text = "Submitted and waiting for fulfillment"; EditableOrderItemsGridView.Visible = false; } else if (currentOrder.InvoicesBypurchaseorder_.Count > 0) { StatusLabel.Text = "Fulfilled"; EditableOrderItemsGridView.Visible = false; } else { StatusLabel.Text = "Waiting to submit"; if (currentOrder.customer_id == homeCompany.company_id) { SubmitButton.Visible = true; FindProductPanel.Visible = true; } EditableOrderItemsGridView.Visible = true; FrozenOrderItemsGridView.Visible = false; } }
/// <summary> /// Gets a collection of Permission objects by a Admin object. /// </summary> /// <param name="admin">admin</param> /// <param name="startRowIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRows"></param> /// <returns>A collection Permission objects.</returns> public static EntityList<Permission> GetPermissionsByauthoriser_(Admin @authoriser_, long startRowIndex, int pageSize, out long totalRows) { string commandText = @" FROM [dbo].[Permissions] WHERE [Permissions].[authoriser_id] = @authoriser_id "; List<SqlParameter> parameters = new List<SqlParameter>(); parameters.Add(new SqlParameter("@authoriser_id", @authoriser_.admin_id)); return GetList<Permission>(SelectFieldList, commandText, parameters, null, startRowIndex, pageSize, out totalRows); }
/// <summary> /// Gets a collection of Permission objects by a Admin object. /// </summary> /// <param name="authoriser_">authoriser_</param> /// <returns>A collection Permission objects.</returns> public static EntityList<Permission> GetPermissionsByauthoriser_(Admin @authoriser_) { string commandText = "PermissionGetByAdmin"; List<SqlParameter> parameters = new List<SqlParameter>(); parameters.Add(new SqlParameter("@authoriser_id", @authoriser_.admin_id)); return GetList<Permission>(@authoriser_, commandText, parameters); }
/// <summary> /// Deletes Permission objects by a Admin object. /// </summary> /// <param name="admin">admin</param> public static void DeletePermissionsByauthoriser_(Admin admin) { string commandText = "PermissionDeleteByAdmin"; System.Collections.Generic.List<SqlParameter> parameters = new System.Collections.Generic.List<SqlParameter>(); parameters.Add(new SqlParameter("@authoriser_id", admin.admin_id)); using (SqlHelper helper = new SqlHelper()) { helper.Execute(commandText, CommandType.StoredProcedure, parameters); } }
/// <summary> /// Create a new Permission object from a Admin object. /// </summary> /// <param name="authoriser_">authoriser_</param> /// <returns>The newly created Permission object.</returns> public static Permission CreatePermissionByauthoriser_(Admin @authoriser_) { Permission permission = InitializeNew<Permission>(); permission.authoriser_id = @authoriser_.admin_id; permission.authoriser_ = @authoriser_; return permission; }
/// <summary> /// Create a new Permission object from a Admin object. /// </summary> /// <param name="admin_">admin_</param> /// <returns>The newly created Permission object.</returns> public static Permission CreatePermissionByadmin_(Admin @admin_) { Permission permission = InitializeNew<Permission>(); permission.admin_id = @admin_.admin_id; permission.admin_ = @admin_; return permission; }
private void AddAdminToCompany(Admin new_admin, string company_position, string role) { Permission new_permission = Permission.CreatePermission(); try { Role admin_role = Role.GetRole(role); new_permission.admin_id = new_admin.admin_id; new_permission.role_name = admin_role; new_permission.company_id = current_company.company_id; new_permission.company_position = company_position; new_permission.authoriser_id = loggedInAdmin.admin_id; new_permission.creation_datetime = DateTime.Now; new_permission.Save(); AdminListErrorLabel.Text = "New administrator has been successfully added. An email has been sent informing them."; } catch (Exception ex) { AdminListErrorLabel.Text = ErrorHelper.generic; } }
protected void Page_Load(object sender, EventArgs e) { AdminListErrorLabel.Text = ""; loggedInAdmin = Helpers.GetLoggedInAdmin(); current_company = Helpers.GetCurrentCompany(); if (!(Helpers.IsAuthorizedOwner(loggedInAdmin, current_company) || Helpers.IsSuperUser(loggedInAdmin))) { Response.Redirect("/status.aspx?msg=notauthorized"); } if (!IsPostBack) { RefreshAdminsGridview(); } }