Esempio n. 1
0
        protected void btnDeleteRolePerm_Click(object sender, EventArgs e)
        {
            //get the permission ID as the command argument
            ImageButton btn          = sender as ImageButton;
            int         permissionID = Int32.Parse(btn.CommandArgument);

            //update the delete panel
            IRolePermissionRepository rolePermRepo = RepositoryFactory.Get <IRolePermissionRepository>();
            var theQuery = from p in rolePermRepo.RolePermissions
                           where p.permissionID == permissionID
                           select p;

            foreach (var thePermission in theQuery)
            {
                this.deleteRoleIDTextBox.Text = thePermission.roleID.ToString();
                this.deleteObjectTextBox.Text = [email protected]();
                this.deleteUpdateTextBox.Text = thePermission.obj_update.ToString();
                this.deleteViewTextBox.Text   = thePermission.obj_view.ToString();
                this.deleteCreateTextBox.Text = thePermission.obj_create.ToString();
                this.deleteDeleteTextBox.Text = thePermission.obj_delete.ToString();

                this.deletePermLabel.Text = permissionID.ToString();
            }

            //turn off the other panels and show the delete panel
            this.editPanel.Visible   = false;
            this.addPanel.Visible    = false;
            this.deletePanel.Visible = true;
        }
Esempio n. 2
0
        private string getOrderPrice(int orderID)
        {
            IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();
            Order            current_order   = orderRepository.GetById(orderID);

            return(string.Format("{0:C}", current_order.price));
        }
Esempio n. 3
0
        protected void deleteSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                IRolePermissionRepository rolePermRepo = RepositoryFactory.Get <IRolePermissionRepository>();
                RolePermission            deleteMe     = rolePermRepo.GetById(int.Parse(deletePermLabel.Text));

                rolePermRepo.DeleteRolePermission(deleteMe.permissionID);

                rolePermRepo.SubmitChanges();

                //return a validation message
                errorLabel.Text    = "Permission has been deleted";
                errorLabel.Visible = true;

                //hide the panel
                deletePanel.Visible = false;
            }
            catch (Exception)
            {
                //error message
                errorLabel.Text    = "Database error when deleting role permission";
                errorLabel.Visible = true;
            }

            updateRolePermissionTable();
        }
Esempio n. 4
0
        public static IQueryable <Order> getOrdersByUser(int userID, HttpResponse r)
        {
            IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();

            IQueryable <Order> orders_User = null;

            if (Security.IsAuthorized(userID, PwasObject.Order, PwasAction.View, PwasScope.All))
            {
                orders_User = from p
                              in orderRepository.Orders
                              select p;
            }
            else if (Security.IsAuthorized(userID, PwasObject.Order, PwasAction.View, PwasScope.Self))
            {
                orders_User = from p
                              in orderRepository.Orders
                              where p.userID == userID
                              select p;
            }
            else
            {
                r.Redirect("index.aspx");
            }
            return(orders_User);
        }
Esempio n. 5
0
        protected void saveOrder(object sender, EventArgs e)
        {
            IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();
            Order            orderCreate;

            if (validateFields())
            {
                orderCreate              = new Order();
                orderCreate.userID       = getUserID();
                orderCreate.job_name     = this.txtJobName.Text;
                orderCreate.width        = Int32.Parse(this.txtFinalSizeX.Text);
                orderCreate.height       = Int32.Parse(this.txtFinalSizeY.Text);
                orderCreate.quantity     = Int32.Parse(this.txtQty.Text);
                orderCreate.stock_finish = this.lstFinish.SelectedValue;
                orderCreate.stock_weight = this.lstWeight.SelectedValue;
                orderCreate.two_sided    = this.chkTwoSide.Checked;
                orderCreate.folded       = this.chkfolded.Checked;
                orderCreate.ship         = this.chkShip.Checked;
                orderCreate.price        = calculatePrice(orderCreate);


                orderRepository.AddOrder(orderCreate);
                orderRepository.SubmitChanges();

                this.lblNotify.Text      = "Order Created Sucessfull!  with ID :" + orderCreate.orderID;
                this.lblNotify.ForeColor = System.Drawing.Color.Blue;
                this.lblNotify.Visible   = true;
                func_clearFields(false);
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["PWAS_UserToEdit"] != null)
            {
                ViewState["PWAS_UserToEdit"] = Session["PWAS_UserToEdit"];
                Session.Remove("PWAS_UserToEdit");
            }

            if (ViewState["PWAS_UserToEdit"] != null)
            {
                tableErrorMessage.Visible = false;
                lblErrorMessage.Visible   = false;
                lblErrorMessage.Style.Add(HtmlTextWriterStyle.Color, "red");

                //need to set as a constant later on
                userId = Convert.ToInt32(ViewState["PWAS_UserToEdit"]);

                IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();
                user = userRepo.GetById(userId);

                if (!IsPostBack)
                {
                    populateInformation();
                }
            }
            else
            {
                Response.Redirect("adminView_ManageAccounts.aspx");
            }
        }
Esempio n. 7
0
        protected void btnEditLoginInfo_Click(object sender, EventArgs e)
        {
            //Email address is used as username and cannot be empty
            if (String.IsNullOrEmpty(txtEmailAddress.Text.Trim()))
            {
                lblErrorMessage.Text      = "Please enter required (*) information";
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                return;
            }
            //Passwords must match
            if (!txtNewPassword.Text.Equals(txtNewPasswordConfirm.Text))
            {
                lblErrorMessage.Text      = "Password fields do not match";
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                return;
            }
            //This information is already in the db and does not need to be saved again
            if (txtEmailAddress.Text.Equals(user.email) && String.IsNullOrEmpty(txtNewPassword.Text))
            {
                return;
            }

            IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();
            User            newUser  = userRepo.GetById((int)Session[Constants.PWAS_SESSION_ID]);

            //If username is changed
            if (!user.email.Equals(txtEmailAddress.Text))
            {
                bool userExists = userRepo.Users.Any(u => u.email.Equals(txtEmailAddress.Text));

                //check to see if email already exists
                if (userExists)
                {
                    lblErrorMessage.Text      = "Username (email) already in use";
                    lblErrorMessage.Visible   = true;
                    tableErrorMessage.Visible = true;
                    //return email already in use error message
                    return;
                }

                newUser.email = txtEmailAddress.Text;
            }

            //if password is changed, add it to the db
            if (!String.IsNullOrEmpty(txtNewPassword.Text.Trim()))
            {
                //Should verify if correct formatting in this step
                newUser.password = Security.MD5Encode(txtNewPassword.Text.Trim());
            }

            //userRepo.UpdateUserInfo(newUser);
            userRepo.SubmitChanges();

            lblErrorMessage.Text = "Request Completed";
            lblErrorMessage.Style.Add(HtmlTextWriterStyle.Color, "green");
            lblErrorMessage.Visible   = true;
            tableErrorMessage.Visible = true;
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["PWAS_run_id"] != null)
            {
                int runID = System.Int32.Parse(Session["PWAS_run_id"].ToString());
                IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();

                var query = from p
                            in orderRepository.Orders
                            where p.runID == runID
                            select p;

                foreach (var current_order in query)
                {
                    TableRow row = new TableRow();

                    TableCell cellOrderID  = new TableCell();
                    TableCell cellJobName  = new TableCell();
                    TableCell cellPrice    = new TableCell();
                    TableCell cellQuantity = new TableCell();



                    cellOrderID.Controls.Add(new LiteralControl(current_order.orderID.ToString()));
                    cellJobName.Controls.Add(new LiteralControl(current_order.job_name.ToString()));
                    cellPrice.Controls.Add(new LiteralControl(String.Format("{0:C}", current_order.price.ToString())));
                    cellQuantity.Controls.Add(new LiteralControl(current_order.quantity.ToString()));

                    //pixels

                    cellOrderID.Width  = Unit.Pixel(100);
                    cellJobName.Width  = Unit.Pixel(200);
                    cellPrice.Width    = Unit.Pixel(150);
                    cellQuantity.Width = Unit.Pixel(150);


                    //Center

                    cellQuantity.HorizontalAlign = HorizontalAlign.Center;
                    cellOrderID.HorizontalAlign  = HorizontalAlign.Center;
                    cellPrice.HorizontalAlign    = HorizontalAlign.Center;


                    row.Cells.Add(cellOrderID);
                    row.Cells.Add(cellJobName);
                    row.Cells.Add(cellQuantity);
                    row.Cells.Add(cellPrice);


                    row.CssClass = "orderRow";

                    this.PrintRunTableView.Rows.Add(row);
                }
            }
            else
            {
                Response.Redirect("view_print_run.aspx");
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Constants.PWAS_SESSION_ID] == null)
            {
                Session.Abandon();
                Response.Redirect("login.aspx");
            }

            IPrintRunRepository PrintRunRepository = RepositoryFactory.Get <IPrintRunRepository>();

            var query = from p
                        in PrintRunRepository.PrintRuns
                        select p;;

            foreach (var pr in query)
            {
                TableCell cellView   = new TableCell();
                TableCell cellstatus = new TableCell();
                TableCell cellaction = new TableCell();
                TableCell cellID     = new TableCell();
                TableCell cellName   = new TableCell();

                cellView.Controls.Add(getViewControl(pr));
                cellstatus.Controls.Add(getStatusControl(pr));
                cellaction.Controls.Add(getActionControl(pr));
                cellID.Text   = pr.runID.ToString();
                cellName.Text = pr.run_name.ToString();

                //----
                cellView.HorizontalAlign   = HorizontalAlign.Center;
                cellstatus.HorizontalAlign = HorizontalAlign.Center;
                cellaction.HorizontalAlign = HorizontalAlign.Center;
                cellID.HorizontalAlign     = HorizontalAlign.Center;

                //----
                cellID.Width     = Unit.Pixel(150);
                cellName.Width   = Unit.Pixel(200);
                cellstatus.Width = Unit.Pixel(200);
                cellaction.Width = Unit.Pixel(100);


                TableRow prrow = new TableRow();

                prrow.Cells.Add(cellView);
                prrow.Cells.Add(cellID);
                prrow.Cells.Add(cellName);
                prrow.Cells.Add(cellstatus);
                prrow.Cells.Add(cellaction);

                prrow.CssClass = "orderRow";
                PrintRunTable.Rows.Add(prrow);
            }
        }
Esempio n. 10
0
        protected void btnUpdateRole_Click(object sender, EventArgs e)
        {
            Button btn        = sender as Button;
            int    userId     = Int32.Parse(btn.CommandArgument.Substring(0, btn.CommandArgument.IndexOf(";")));
            int    ddRolesRow = Int32.Parse(btn.CommandArgument.Substring(btn.CommandArgument.IndexOf(";") + 1));

            DropDownList    ddRoles   = (DropDownList)(tableManageUsers.Rows[ddRolesRow].Cells[5].Controls[0]);
            int             newRoleId = Int32.Parse(ddRoles.SelectedValue);
            IUserRepository userRepo  = RepositoryFactory.Get <IUserRepository>();

            userRepo.UpdateUserRole(userId, newRoleId);
        }
Esempio n. 11
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            //check that required fields are not empty
            if (!areReqFieldsEmpty())
            {
                lblErrorMessage.Text      = "Please enter required (*) information";
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                return;
            }

            //validate input -> prints error message if any
            string errorMessage = string.Empty;

            if (!areAllFieldsValid(out errorMessage))
            {
                lblErrorMessage.Text      = errorMessage;
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                return;
            }

            IUserRepository userRepo   = RepositoryFactory.Get <IUserRepository>();
            bool            userExists = userRepo.Users.Any(u => u.email.Equals(txtEmailAddress.Text));

            if (userExists)
            {
                lblErrorMessage.Text      = "Username (email) already in use";
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                //return email already in use error message
                return;
            }

            User newUser = new User();

            newUser.email      = txtEmailAddress.Text.Trim();
            newUser.password   = Security.MD5Encode(txtPassword.Text.Trim());
            newUser.firstName  = txtFirstName.Text.Trim();
            newUser.lastName   = txtLastName.Text.Trim();
            newUser.company    = txtCompanyName.Text.Trim();
            newUser.homePhone  = txtPhoneNumber.Text.Trim();
            newUser.b_address1 = txtBillAddressLine1.Text.Trim();
            newUser.b_address2 = txtBillAddressLine2.Text.Trim();
            newUser.b_city     = txtBillCity.Text.Trim();
            newUser.b_state    = txtBillState.Text.Trim();
            newUser.b_zip      = txtBillZipCode.Text.Trim();

            userRepo.AddUser(newUser);
            userRepo.SubmitChanges();

            Response.Redirect("/index.aspx");
        }
Esempio n. 12
0
        public static Status getCurrentOrderStatus(int orderID)
        {
            IOrderRepository  orderRepository = RepositoryFactory.Get <IOrderRepository>();
            IStatusRepository statusReposiory = RepositoryFactory.Get <IStatusRepository>();

            Order currentOrder = orderRepository.GetById(orderID);

            int tempStatus = (int)currentOrder.currentStatus;

            Status currentStatus = statusReposiory.GetById(tempStatus);

            return(currentStatus);
        }
Esempio n. 13
0
        protected void btnDeleteUser_Click(object sender, EventArgs e)
        {
            ImageButton btn    = sender as ImageButton;
            int         userId = Int32.Parse(btn.CommandArgument);

            IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();

            userRepo.DeactivateUser(userId);
            userRepo.SubmitChanges();


            Response.Redirect("adminView_ManageAccounts.aspx");
        }
Esempio n. 14
0
        internal static bool isMyOrder(int orderID, int userID)
        {
            IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();
            Order            currentOrder    = orderRepository.GetById(orderID);

            if (currentOrder.userID == userID)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 15
0
        protected void btnEditOtherInfo_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtFirstName.Text.Trim()) ||
                String.IsNullOrEmpty(txtLastName.Text.Trim()) ||
                String.IsNullOrEmpty(txtPhoneNumber.Text.Trim()) ||
                String.IsNullOrEmpty(txtBillAddressLine1.Text.Trim()) ||
                String.IsNullOrEmpty(txtBillCity.Text.Trim()) ||
                String.IsNullOrEmpty(txtBillState.Text.Trim()) ||
                String.IsNullOrEmpty(txtBillZipCode.Text.Trim()))
            {
                lblErrorMessage.Text      = "Please enter required (*) information";
                lblErrorMessage.Visible   = true;
                tableErrorMessage.Visible = true;
                return;
            }

            IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();
            User            newUser  = userRepo.GetById((int)Session[Constants.PWAS_SESSION_ID]);

            newUser.firstName = txtFirstName.Text.Trim();
            newUser.lastName  = txtLastName.Text.Trim();
            newUser.company   = txtCompanyName.Text.Trim();
            newUser.homePhone = txtPhoneNumber.Text.Trim();

            newUser.cc_num        = txtCreditCardNumber.Text.Trim();
            newUser.cc_type       = ddCardType.SelectedValue;
            newUser.exp_date      = txtExpDate.Text.Trim();
            newUser.cc_scode      = txtSecurityCode.Text.Trim();
            newUser.cc_nameOnCard = txtNameOnCard.Text.Trim();

            newUser.b_address1 = txtBillAddressLine1.Text.Trim();
            newUser.b_address2 = txtBillAddressLine2.Text.Trim();
            newUser.b_city     = txtBillCity.Text.Trim();
            newUser.b_state    = txtBillState.Text.Trim();
            newUser.b_zip      = txtBillZipCode.Text.Trim();

            newUser.s_address1 = txtShipAddressLine1.Text.Trim();
            newUser.s_address2 = txtShipAddressLine2.Text.Trim();
            newUser.s_city     = txtShipCity.Text.Trim();
            newUser.s_state    = txtShipState.Text.Trim();
            newUser.s_zip      = txtShipZipCode.Text.Trim();

            //userRepo.UpdateUserInfo(newUser);
            userRepo.SubmitChanges();

            lblErrorMessage.Text = "Request Completed";
            lblErrorMessage.Style.Add(HtmlTextWriterStyle.Color, "green");
            lblErrorMessage.Visible   = true;
            tableErrorMessage.Visible = true;
        }
Esempio n. 16
0
        private void loadOrderTable()
        {
            //load active orders and populate tableCreatedOrders
            IOrderRepository orderRepo  = RepositoryFactory.Get <IOrderRepository>();
            List <Order>     paidOrders = orderRepo.Orders.Where(o => o.currentStatus == OrderConstants.ORDER_STATUS_PAID).ToList <Order>();
            bool             canSelect  = Security.IsAuthorized((int)Session[Constants.PWAS_SESSION_ID], PwasObject.PrintRun, PwasAction.Update, PwasScope.All);

            foreach (Order order in paidOrders)
            {
                TableRow tableRow = new TableRow();
                tableRow.CssClass = "orderRow";


                TableCell cellSelect = new TableCell();
                CheckBox  check      = new CheckBox();
                check.Enabled = canSelect;
                cellSelect.Controls.Add(check);

                TableCell orderID = new TableCell();
                orderID.Text = order.orderID.ToString();

                TableCell orderName = new TableCell();
                orderName.Text = order.job_name.ToString();

                TableCell orderQuantity = new TableCell();
                orderQuantity.Text = order.quantity.ToString();

                TableCell orderHeight = new TableCell();
                orderHeight.Text = order.height.ToString();

                TableCell orderWidth = new TableCell();
                orderWidth.Text = order.width.ToString();

                cellSelect.Width    = Unit.Pixel(60);
                orderID.Width       = Unit.Pixel(60);
                orderName.Width     = Unit.Pixel(150);
                orderQuantity.Width = Unit.Pixel(100);
                orderHeight.Width   = Unit.Pixel(100);
                orderWidth.Width    = Unit.Pixel(100);

                tableRow.Cells.Add(cellSelect);
                tableRow.Cells.Add(orderID);
                tableRow.Cells.Add(orderName);
                tableRow.Cells.Add(orderQuantity);
                tableRow.Cells.Add(orderHeight);
                tableRow.Cells.Add(orderWidth);

                tableCreatedOrders.Rows.Add(tableRow);
            }
        }
Esempio n. 17
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //this is the edit button click (it's misnamed)
            //as long as the item in the list box is not null, then get the role and update it
            if (!string.IsNullOrEmpty(editLabel.Text))
            {
                if (String.IsNullOrEmpty(editRoleNameBox.Text.Trim()) || String.IsNullOrEmpty(editRoleDescBox.Text.Trim()))
                {
                    //either the desc or name are null - send a error message to the user and do not add the role
                    errorMessageLabel.Text    = "Please enter a value for both Role Name and Role Description";
                    errorMessageLabel.Visible = true;
                }
                else
                {
                    try
                    {
                        IRoleRepository roleRepo = RepositoryFactory.Get <IRoleRepository>();

                        //get the role indicated by the listbox number
                        Role updateMe = roleRepo.GetById(int.Parse(editLabel.Text));

                        //update the role
                        updateMe.role_name = editRoleNameBox.Text;
                        updateMe.role_desc = editRoleDescBox.Text;

                        roleRepo.SubmitChanges();

                        errorMessageLabel.Text    = "Role has been editted";
                        errorMessageLabel.Visible = true;
                    }
                    catch (Exception)
                    {
                        //respond with error message
                        errorMessageLabel.Text    = "Database error when editting role";
                        errorMessageLabel.Visible = true;
                    }

                    //clear the text boxes
                    editRoleNameBox.Text = "";
                    editRoleDescBox.Text = "";

                    //hide the panel
                    editPanel.Visible = false;

                    //update the role table to reflect changes
                    updateRoleTable();
                }
            }
        }
Esempio n. 18
0
        protected void editSubmit_Click(object sender, EventArgs e)
        {
            //check for nulls
            if ((String.IsNullOrEmpty(editRoleIDTextBox.Text)) ||
                (String.IsNullOrEmpty(editObjectTextBox.Text)) ||
                (String.IsNullOrEmpty(editUpdateTextBox.Text)) ||
                (String.IsNullOrEmpty(editViewTextBox.Text)) ||
                (String.IsNullOrEmpty(editCreateTextBox.Text)) ||
                (String.IsNullOrEmpty(editDeleteTextBox.Text)))
            {
                //return a error message
                errorLabel.Text    = "Please enter a valid value for all fields";
                errorLabel.Visible = true;
            }
            else
            {
                try
                {
                    IRolePermissionRepository rolePermRepo = RepositoryFactory.Get <IRolePermissionRepository>();
                    RolePermission            editMe       = rolePermRepo.GetById(int.Parse(editPermLabel.Text));

                    editMe.obj_create = int.Parse(editCreateTextBox.Text);
                    editMe.obj_delete = int.Parse(editDeleteTextBox.Text);
                    editMe.obj_update = int.Parse(editUpdateTextBox.Text);
                    editMe.obj_view   = int.Parse(editViewTextBox.Text);
                    editMe.@object    = editObjectTextBox.Text;
                    editMe.roleID     = int.Parse(editRoleIDTextBox.Text);

                    //rolePermRepo.editRolePermission(editMe);

                    rolePermRepo.SubmitChanges();

                    //return a validation message
                    errorLabel.Text    = "Permission has been editted";
                    errorLabel.Visible = true;

                    //hide the panel
                    editPanel.Visible = false;
                }
                catch (Exception)
                {
                    //error message
                    errorLabel.Text    = "Database error when editing role permission";
                    errorLabel.Visible = true;
                }

                updateRolePermissionTable();
            }
        }
Esempio n. 19
0
        protected void addSubmit_Click(object sender, EventArgs e)
        {
            //check for nulls
            if ((String.IsNullOrEmpty(addRoleIDTextBox.Text)) ||
                (String.IsNullOrEmpty(addObjectTextBox.Text)) ||
                (String.IsNullOrEmpty(addUpdateTextBox.Text)) ||
                (String.IsNullOrEmpty(addViewTextBox.Text)) ||
                (String.IsNullOrEmpty(addCreateTextBox.Text)) ||
                (String.IsNullOrEmpty(addDeleteTextBox.Text)))
            {
                //return a error message
                errorLabel.Text    = "Please enter a valid value for all fields";
                errorLabel.Visible = true;
            }
            else
            {
                try
                {
                    IRolePermissionRepository rolePermRepo = RepositoryFactory.Get <IRolePermissionRepository>();
                    RolePermission            addMe        = new RolePermission();

                    addMe.obj_create = int.Parse(addCreateTextBox.Text);
                    addMe.obj_delete = int.Parse(addDeleteTextBox.Text);
                    addMe.obj_update = int.Parse(addUpdateTextBox.Text);
                    addMe.obj_view   = int.Parse(addViewTextBox.Text);
                    addMe.@object    = addObjectTextBox.Text;
                    addMe.roleID     = int.Parse(addRoleIDTextBox.Text);

                    rolePermRepo.AddRolePermission(addMe);

                    rolePermRepo.SubmitChanges();

                    //return a validation message
                    errorLabel.Text    = "New Permission has been added";
                    errorLabel.Visible = true;

                    //hide the panel
                    addPanel.Visible = false;
                }
                catch (Exception)
                {
                    //error message
                    errorLabel.Text    = "Database error when adding role permission";
                    errorLabel.Visible = true;
                }

                updateRolePermissionTable();
            }
        }
Esempio n. 20
0
        public static string getCurrentOrderStatusDate(int orderID)
        {
            IOrderRepository        orderRepository   = RepositoryFactory.Get <IOrderRepository>();
            IOrderHistoryRepository historyRepository = RepositoryFactory.Get <IOrderHistoryRepository>();

            Order currentOrder = orderRepository.GetById(orderID);
            //OrderHistory currentHistory = historyRepository.OrderHistories.Single(x => x.orderId == orderID
            //                                                    && x.statusId == currentOrder.Status.statusId);
            OrderHistory currentHistory = (from history in historyRepository.OrderHistories
                                           where history.orderId == orderID && history.statusId == currentOrder.currentStatus
                                           orderby history.modifiedDate descending
                                           select history).First();

            return(currentHistory.modifiedDate.ToString());
        }
Esempio n. 21
0
        private void func_Pay(object sender, CommandEventArgs e)
        {
            IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();
            User            user     = userRepo.GetById((int)Session[Constants.PWAS_SESSION_ID]);

            //If the user is a customer, test the user profile
            if (user.roleID == 1)
            {
                if (!(validateUserBillingAddress(user) && validateUserCreditCardInfo(user)))
                {
                    panelAlert.Visible = true;
                    return;
                }
            }
            //If the user is not a customer, test the profile for the customer attached to the order
            else
            {
                Button btn     = (Button)sender;
                int    orderId = Int32.Parse(btn.CommandArgument);

                IOrderRepository orderRepo = RepositoryFactory.Get <IOrderRepository>();
                Order            order     = orderRepo.GetById(orderId);
                user = userRepo.GetById(order.userID);

                if (!(validateUserBillingAddress(user) && validateUserCreditCardInfo(user)))
                {
                    if (user == userRepo.GetById((int)Session[Constants.PWAS_SESSION_ID]))
                    {
                        panelAlert.Visible = true;
                    }
                    else
                    {
                        panelAlertEmployee.Visible = true;
                    }
                    return;
                }
            }

            this.lblNotify.Text      = "Order Sucessfully Paid!";
            this.lblNotify.ForeColor = System.Drawing.Color.Blue;
            this.lblNotify.Visible   = true;

            int orderID = System.Int32.Parse(e.CommandArgument.ToString());

            RepositoryFactory.Get <IOrderRepository>().UpdateOrderStatus(orderID, 2);

            Response.Redirect(Request.Url.ToString());
        }
Esempio n. 22
0
        private void loadPrintRunList()
        {
            if (runList.Items.Count == 0)
            {
                IPrintRunRepository prRepo = RepositoryFactory.Get <IPrintRunRepository>();
                List <PrintRun>     prList = prRepo.PrintRuns.Where(p => p.run_status == OrderConstants.ORDER_STATUS_CREATED).ToList <PrintRun>();

                ListItem tempItem;

                foreach (PrintRun pr in prList)
                {
                    tempItem       = new ListItem("Run " + pr.runID + " - " + pr.run_name, pr.runID.ToString());
                    tempItem.Value = pr.runID.ToString();
                    runList.Items.Add(tempItem);
                }
            }
        }
Esempio n. 23
0
        protected void addSubmit_Click(object sender, EventArgs e)
        {
            //check to make sure the data is not null

            if (String.IsNullOrEmpty(addRoleDescBox.Text.Trim()) || String.IsNullOrEmpty(addRoleNameBox.Text.Trim()))
            {
                //either the desc or name are null - send a error message to the user and do not add the role
                errorMessageLabel.Text    = "Please enter a value for both Role Name and Role Description";
                errorMessageLabel.Visible = true;
            }
            else
            {
                try
                {
                    //access the database and add the new role, submit
                    IRoleRepository roleRepo = RepositoryFactory.Get <IRoleRepository>();

                    Role newRole = new Role();

                    newRole.role_desc = addRoleDescBox.Text;
                    newRole.role_name = addRoleNameBox.Text;

                    roleRepo.AddRole(newRole);
                    roleRepo.SubmitChanges();

                    errorMessageLabel.Text    = "Role has been added";
                    errorMessageLabel.Visible = true;
                }
                catch (Exception)
                {
                    //error message
                    errorMessageLabel.Text    = "Database error when inserting new role";
                    errorMessageLabel.Visible = true;
                }

                //clear the text boxes
                addRoleNameBox.Text = "";
                addRoleDescBox.Text = "";

                //hide the panel
                addPanel.Visible = false;

                //update the role table to reflect changes
                updateRoleTable();
            }
        }
Esempio n. 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            tableErrorMessage.Visible = false;
            lblErrorMessage.Visible   = false;
            lblErrorMessage.Style.Add(HtmlTextWriterStyle.Color, "red");

            userId = Convert.ToInt32(Session[Constants.PWAS_SESSION_ID]);

            IUserRepository userRepo = RepositoryFactory.Get <IUserRepository>();

            user = userRepo.GetById(userId);

            if (!IsPostBack)
            {
                populateInformation();
            }
        }
Esempio n. 25
0
        protected void doSubmit(object sender, EventArgs e)
        {
            int  i = 0;
            bool somethingSelected = false;

            List <TableRow> toDelete = new List <TableRow>();

            foreach (TableRow row in tableCreatedOrders.Rows)
            {
                if (i > 0)//skip the first row, since it's the header row
                {
                    TableCell tempCell = row.Cells[0];
                    if (((CheckBox)tempCell.Controls[0]).Checked)
                    {
                        somethingSelected = true;
                        IOrderRepository orderRepo = RepositoryFactory.Get <IOrderRepository>();
                        orderRepo.UpdateOrderStatus(Int32.Parse(row.Cells[1].Text), OrderConstants.ORDER_STATUS_PROCESSING);
                        orderRepo.UpdateOrderRunId(Int32.Parse(row.Cells[1].Text), Int32.Parse(runList.SelectedValue));
                        toDelete.Add(row);
                    }
                }

                i++;
            }

            if (somethingSelected)
            {
                IPrintRunRepository prRepo = RepositoryFactory.Get <IPrintRunRepository>();
                prRepo.UpdatePrintRunStatus(Int32.Parse(runList.SelectedValue), OrderConstants.ORDER_STATUS_PREPRINTING);

                //1.delete the selected rows from "tableCreatedOrders"
                //2.delete the selected print run from the drop down "runList"

                foreach (TableRow row in toDelete)
                {
                    tableCreatedOrders.Rows.Remove(row);
                }

                runList.Items.Remove(runList.SelectedItem);

                messageNotify.Text      = "Your orders have been added to the print run successfully.";
                messageNotify.ForeColor = System.Drawing.Color.Green;
                messageNotify.Visible   = true;
            }
        }
Esempio n. 26
0
        public void UpdateOrderStatus_PrintRun(int printRundId, int statusID)
        {
            IPrintRunRepository printRepo = RepositoryFactory.Get <IPrintRunRepository>();
            IOrderRepository    orderRepo = RepositoryFactory.Get <IOrderRepository>();


            PrintRun printRun = printRepo.GetById(printRundId);

            var orders = from p
                         in orderRepo.Orders
                         where p.PrintRun.runID == printRundId
                         select p;

            foreach (var cur_Order in orders)
            {
                orderRepo.UpdateOrderStatus(cur_Order.orderID, statusID);
            }
        }
Esempio n. 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IOrderRepository orderRepository = RepositoryFactory.Get <IOrderRepository>();
            int userID = 1007;// (int)Session[Constants.PWAS_SESSION_ID];

            /*
             * try
             * {
             *  userID = (int)Session[Constants.PWAS_SESSION_ID];
             * }
             * catch (Exception exception)
             * {
             *  Response.Redirect("/login.aspx");
             * }*/

            var query = from p in orderRepository.Orders where p.userID == userID select p;


            foreach (var ord in query)
            {
                TableRow row = new TableRow();

                TableCell cellOrderID = new TableCell();
                TableCell cellJobName = new TableCell();
                TableCell cellStatus  = new TableCell();
                TableCell cellDate    = new TableCell();

                cellOrderID.Controls.Add(new LiteralControl(ord.orderID.ToString()));
                cellJobName.Controls.Add(new LiteralControl(ord.job_name.ToString()));
                cellStatus.Controls.Add(getStatusControl(ord.orderID));

                cellDate.Controls.Add(new LiteralControl(getCurrentOrderStatusDate()));

                row.Cells.Add(cellOrderID);
                row.Cells.Add(cellJobName);
                row.Cells.Add(cellStatus);
                row.Cells.Add(cellDate);

                row.CssClass = "orderRow";

                this.orderHistoryTable.Rows.Add(row);
            }
        }
Esempio n. 28
0
        private void updateDeletePanel(int roleID)
        {
            IRoleRepository roleRepo = RepositoryFactory.Get <IRoleRepository>();

            try
            {
                Role displayMe = new Role();
                displayMe = roleRepo.GetById(roleID);

                deleteLabel.Text       = roleID.ToString();
                deleteRoleDescBox.Text = displayMe.role_desc;
                deleteRoleNameBox.Text = displayMe.role_name;
            }
            catch (Exception)
            {
                errorMessageLabel.Text    = "Error retrieving role from the database";
                errorMessageLabel.Visible = true;
            }
        }
Esempio n. 29
0
        private Control getStatusControl(PrintRun pr)
        {
            DropDownList dropListStatus = new DropDownList();

            dropListStatus.ID = pr.runID.ToString();

            IStatusRepository statusRepository = RepositoryFactory.Get <IStatusRepository>();
            var query = statusRepository.Statuses.ToList();

            foreach (int statusID in Enum.GetValues(typeof(PWAS_Site.PrintRunStatus)))
            {
                if (statusID != OrderConstants.ORDER_STATUS_CREATED)
                {
                    ListItem lsItem = new ListItem(statusRepository.GetById(statusID).statusName);
                    dropListStatus.Items.Add(lsItem);

                    if (pr.Status.statusId == statusID)
                    {
                        dropListStatus.SelectedIndex = dropListStatus.Items.IndexOf(lsItem);
                    }

                    if (pr.Status.statusId == OrderConstants.ORDER_STATUS_CLOSED)
                    {
                        dropListStatus.Enabled = false;
                    }
                }
            }

            if (pr.Status.statusId == OrderConstants.ORDER_STATUS_CREATED)
            {
                ListItem lsItem = new ListItem(statusRepository.GetById(pr.Status.statusId).statusName);
                dropListStatus.Items.Add(lsItem);
                dropListStatus.SelectedIndex = dropListStatus.Items.IndexOf(lsItem);
                dropListStatus.Enabled       = false;
            }

            dropListStatus.Width = Unit.Pixel(200);
            dropListStatus.SelectedIndexChanged += new EventHandler(func_selected);
            dropListStatus.AutoPostBack          = true;

            return(dropListStatus);
        }
Esempio n. 30
0
        protected void deleteSubmit_Click(object sender, EventArgs e)
        {
            //as long as the roleID in the label is not null, then get the role and delete it
            if (String.IsNullOrEmpty(deleteLabel.Text) == false)
            {
                try
                {
                    IRoleRepository roleRepo = RepositoryFactory.Get <IRoleRepository>();

                    //get the role indicated by the listbox number
                    Role deleteMe = roleRepo.GetById(int.Parse(deleteLabel.Text));

                    //delete the role
                    roleRepo.DeleteRole(deleteMe.roleID);

                    //try to submit
                    roleRepo.SubmitChanges();

                    errorMessageLabel.Text = "Role has been deleted";
                }
                catch (Exception)
                {
                    //delete failed - a user is assigned to this role
                    errorMessageLabel.Text    = "Cannot delete this role - a user is assigned to it";
                    errorMessageLabel.Visible = true;
                }

                //clear the text boxes
                deleteRoleNameBox.Text = "";
                deleteRoleDescBox.Text = "";
                deleteLabel.Text       = "";

                //hide the panel
                deletePanel.Visible = false;

                //redraw the role table to reflect the change
                updateRoleTable();
            }
        }