Example #1
0
        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();
               }
        }
        /// <summary>
        /// Gets a collection of Permission objects by a Company object.
        /// </summary>
        /// <param name="company_">company_</param>
        /// <returns>A collection Permission objects.</returns>
        public static EntityList<Permission> GetPermissionsBycompany_(Company @company_)
        {
            string commandText = "PermissionGetByCompany";

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@company_id", @company_.company_id));

            return GetList<Permission>(@company_, commandText, parameters);
        }
        /// <summary>
        /// Create a new Permission object from a Company object.
        /// </summary>
        /// <param name="company_">company_</param>
        /// <returns>The newly created Permission object.</returns>
        public static Permission CreatePermissionBycompany_(Company @company_)
        {
            Permission permission = InitializeNew<Permission>();

            permission.company_id = @company_.company_id;

            permission.company_ = @company_;

            return permission;
        }
        /// <summary>
        /// Create a new Invoice object from a Company object.
        /// </summary>
        /// <param name="customer_">customer_</param>
        /// <returns>The newly created Invoice object.</returns>
        public static Invoice CreateInvoiceBycustomer_(Company @customer_)
        {
            Invoice invoice = InitializeNew<Invoice>();

            invoice.customer_id = @customer_.company_id;

            invoice.customer_ = @customer_;

            return invoice;
        }
        /// <summary>
        /// Create a new Invoice object from a Company object.
        /// </summary>
        /// <param name="supplier_">supplier_</param>
        /// <returns>The newly created Invoice object.</returns>
        public static Invoice CreateInvoiceBysupplier_(Company @supplier_)
        {
            Invoice invoice = InitializeNew<Invoice>();

            invoice.supplier_id = @supplier_.company_id;

            invoice.supplier_ = @supplier_;

            return invoice;
        }
        /// <summary>
        /// Gets a collection of AllowedStore objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="orderBy"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection AllowedStore objects.</returns>
        protected static EntityList<AllowedStore> GetAllowedStoresBysupplier_(Company @supplier_, string orderBy, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[AllowedStores]
            WHERE
            [AllowedStores].[supplier_id] = @supplier_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@supplier_id", @supplier_.company_id));

            return GetList<AllowedStore>(SelectFieldList, commandText, parameters, orderBy, startRowIndex, pageSize, out totalRows);
        }
        /// <summary>
        /// Gets a collection of AllowedStore objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection AllowedStore objects.</returns>
        public static EntityList<AllowedStore> GetAllowedStoresBycustomer_(Company @customer_, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[AllowedStores]
            WHERE
            [AllowedStores].[customer_id] = @customer_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@customer_id", @customer_.company_id));

            return GetList<AllowedStore>(SelectFieldList, commandText, parameters, null, startRowIndex, pageSize, out totalRows);
        }
        /// <summary>
        /// Create a new AllowedStore object from a Company object.
        /// </summary>
        /// <param name="supplier_">supplier_</param>
        /// <returns>The newly created AllowedStore object.</returns>
        public static AllowedStore CreateAllowedStoreBysupplier_(Company @supplier_)
        {
            AllowedStore allowedStore = InitializeNew<AllowedStore>();

            allowedStore.supplier_id = @supplier_.company_id;

            allowedStore.supplier_ = @supplier_;

            return allowedStore;
        }
        /// <summary>
        /// Gets a collection of Permission objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection Permission objects.</returns>
        public static EntityList<Permission> GetPermissionsBycompany_(Company @company_, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[Permissions]
            WHERE
            [Permissions].[company_id] = @company_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@company_id", @company_.company_id));

            return GetList<Permission>(SelectFieldList, commandText, parameters, null, startRowIndex, pageSize, out totalRows);
        }
Example #14
0
        /// <summary>
        /// Gets a collection of Access objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="orderBy"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection Access objects.</returns>
        protected static EntityList<Access> GetAccessesBycompany_(Company @company_, string orderBy, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[Accesses]
            WHERE
            [Accesses].[company_id] = @company_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@company_id", @company_.company_id));

            return GetList<Access>(SelectFieldList, commandText, parameters, orderBy, startRowIndex, pageSize, out totalRows);
        }
Example #15
0
        /// <summary>
        /// Gets a collection of Access objects by a Company object.
        /// </summary>
        /// <param name="company_">company_</param>
        /// <returns>A collection Access objects.</returns>
        public static EntityList<Access> GetAccessesBycompany_(Company @company_)
        {
            string commandText = "AccessGetByCompany";

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@company_id", @company_.company_id));

            return GetList<Access>(@company_, commandText, parameters);
        }
Example #16
0
        /// <summary>
        /// Create a new Access object from a Company object.
        /// </summary>
        /// <param name="company_">company_</param>
        /// <returns>The newly created Access object.</returns>
        public static Access CreateAccessBycompany_(Company @company_)
        {
            Access access = InitializeNew<Access>();

            access.company_id = @company_.company_id;

            access.company_ = @company_;

            return access;
        }
        /// <summary>
        /// Gets a collection of Invoice objects by a Company object.
        /// </summary>
        /// <param name="customer_">customer_</param>
        /// <returns>A collection Invoice objects.</returns>
        public static EntityList<Invoice> GetInvoicesBycustomer_(Company @customer_)
        {
            string commandText = "InvoiceGetByCompany";

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@customer_id", @customer_.company_id));

            return GetList<Invoice>(@customer_, commandText, parameters);
        }
        /// <summary>
        /// Create a new AllowedStore object from a Company object.
        /// </summary>
        /// <param name="customer_">customer_</param>
        /// <returns>The newly created AllowedStore object.</returns>
        public static AllowedStore CreateAllowedStoreBycustomer_(Company @customer_)
        {
            AllowedStore allowedStore = InitializeNew<AllowedStore>();

            allowedStore.customer_id = @customer_.company_id;

            allowedStore.customer_ = @customer_;

            return allowedStore;
        }
        /// <summary>
        /// Gets a collection of PurchaseOrder objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="orderBy"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection PurchaseOrder objects.</returns>
        protected static EntityList<PurchaseOrder> GetPurchaseOrdersBycustomer_(Company @customer_, string orderBy, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[PurchaseOrders]
            WHERE
            [PurchaseOrders].[customer_id] = @customer_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@customer_id", @customer_.company_id));

            return GetList<PurchaseOrder>(SelectFieldList, commandText, parameters, orderBy, startRowIndex, pageSize, out totalRows);
        }
        /// <summary>
        /// Deletes AllowedStore objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        public static void DeleteAllowedStoresBysupplier_(Company company)
        {
            string commandText = "AllowedStoreDeleteByCompany";

            System.Collections.Generic.List<SqlParameter> parameters = new System.Collections.Generic.List<SqlParameter>();
            parameters.Add(new SqlParameter("@supplier_id", company.company_id));

            using (SqlHelper helper = new SqlHelper())
            {
                helper.Execute(commandText, CommandType.StoredProcedure, parameters);
            }
        }
        /// <summary>
        /// Create a new PurchaseOrder object from a Company object.
        /// </summary>
        /// <param name="customer_">customer_</param>
        /// <returns>The newly created PurchaseOrder object.</returns>
        public static PurchaseOrder CreatePurchaseOrderBycustomer_(Company @customer_)
        {
            PurchaseOrder purchaseOrder = InitializeNew<PurchaseOrder>();

            purchaseOrder.customer_id = @customer_.company_id;

            purchaseOrder.customer_ = @customer_;

            return purchaseOrder;
        }
        /// <summary>
        /// Gets a collection of AllowedStore objects by a Company object.
        /// </summary>
        /// <param name="supplier_">supplier_</param>
        /// <returns>A collection AllowedStore objects.</returns>
        public static EntityList<AllowedStore> GetAllowedStoresBysupplier_(Company @supplier_)
        {
            string commandText = "AllowedStoreGetByCompany";

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@supplier_id", @supplier_.company_id));

            return GetList<AllowedStore>(@supplier_, commandText, parameters);
        }
        /// <summary>
        /// Create a new PurchaseOrder object from a Company object.
        /// </summary>
        /// <param name="supplier_">supplier_</param>
        /// <returns>The newly created PurchaseOrder object.</returns>
        public static PurchaseOrder CreatePurchaseOrderBysupplier_(Company @supplier_)
        {
            PurchaseOrder purchaseOrder = InitializeNew<PurchaseOrder>();

            purchaseOrder.supplier_id = @supplier_.company_id;

            purchaseOrder.supplier_ = @supplier_;

            return purchaseOrder;
        }
Example #24
0
        public static void SendXMLOrder(string person, Company customer, Company supplier, string orderXML)
        {
            // create mail message object
               MailMessage mail = new MailMessage();
               mail.From = new MailAddress(sender);		       // put the from address here
               mail.To.Add(new MailAddress(supplier.transactions_email));             // put to address here
               mail.CC.Add(new MailAddress(customer.transactions_email));
               //mail.Bcc.Add(new MailAddress(backupAddress));
               mail.Subject = "New purchase order from " + person + " at " + customer.name;			  // put subject here

               mail.Body = orderXML;

               SmtpClient client = new SmtpClient();
               try
               {
                    client.Send(mail);
               }
               catch (Exception ex)
               {
                    throw ex;
               }
        }
        /// <summary>
        /// Deletes PurchaseOrder objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        public static void DeletePurchaseOrdersBycustomer_(Company company)
        {
            string commandText = "PurchaseOrderDeleteByCompany";

            System.Collections.Generic.List<SqlParameter> parameters = new System.Collections.Generic.List<SqlParameter>();
            parameters.Add(new SqlParameter("@customer_id", company.company_id));

            using (SqlHelper helper = new SqlHelper())
            {
                helper.Execute(commandText, CommandType.StoredProcedure, parameters);
            }
        }
        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 PurchaseOrder objects by a Company object.
        /// </summary>
        /// <param name="supplier_">supplier_</param>
        /// <returns>A collection PurchaseOrder objects.</returns>
        public static EntityList<PurchaseOrder> GetPurchaseOrdersBysupplier_(Company @supplier_)
        {
            string commandText = "PurchaseOrderGetByCompany";

            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@supplier_id", @supplier_.company_id));

            return GetList<PurchaseOrder>(@supplier_, commandText, parameters);
        }
        /// <summary>
        /// Gets a collection of PurchaseOrder objects by a Company object.
        /// </summary>
        /// <param name="company">company</param>
        /// <param name="startRowIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns>A collection PurchaseOrder objects.</returns>
        public static EntityList<PurchaseOrder> GetPurchaseOrdersBysupplier_(Company @supplier_, long startRowIndex, int pageSize, out long totalRows)
        {
            string commandText = @"
            FROM
            [dbo].[PurchaseOrders]
            WHERE
            [PurchaseOrders].[supplier_id] = @supplier_id ";

            List<SqlParameter> parameters = new List<SqlParameter>();

            parameters.Add(new SqlParameter("@supplier_id", @supplier_.company_id));

            return GetList<PurchaseOrder>(SelectFieldList, commandText, parameters, null, startRowIndex, pageSize, out totalRows);
        }
Example #29
0
        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();
               }
        }