Ejemplo n.º 1
0
    protected void MoveUp_Click(object sender, EventArgs e)
    {
        //code to go here
        if (PlayList.Rows.Count == 0)
        {
            MessageUserControl.ShowInfo("Warning", "No play lists has been retrieved");
        }
        else
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Warning", "No play list name has been supplied");
            }
            else
            {
                //check only one row selected
                int trackid     = 0;
                int tracknumber = 0;               //optional
                int rowselected = 0;               //search flagg

                CheckBox playlistselection = null; //create a pointer to use for the access of the GRidView control

                //traverse the gridview checking each row for a checked CheckBox

                for (int i = 0; i < PlayList.Rows.Count; i++)
                {
                    //find the checkbof on the indexed gridview row . Playlistselection will point to the checkbox

                    playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;

                    //if checked
                    if (playlistselection.Checked)
                    {
                        trackid     = int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text);
                        tracknumber = int.Parse((PlayList.Rows[i].FindControl("TrackNumber") as Label).Text);

                        rowselected++;
                    }//eofor
                    if (rowselected != 1)
                    {
                        MessageUserControl.ShowInfo("Warning", "Select one track to move.");
                    }
                    else
                    {
                        if (tracknumber == 1)
                        {
                            MessageUserControl.ShowInfo("Information", "Track cannot be moved. ALready top of the list");
                        }
                        else
                        {
                            //at this point you have
                            //playlistname, username, trackid which is neeeded to move the track

                            //Move the track via your BLL
                            MoveTrack(trackid, tracknumber, "up");
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
        protected void CurrentOrders_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Ship")
            {
                // Gather information from the form to send to the BLL for shipping
                // public void ShipOrder(int orderId, ShippingDirections shipping, List<ShippedItem> items)
                int   orderId    = 0;
                Label ordIdLabel = e.Item.FindControl("OrderIdLabel") as Label; // safe cast the control object to a label opbject
                if (ordIdLabel != null)
                {
                    orderId = int.Parse(ordIdLabel.Text);
                }

                ShippingDirections shipInfo        = new ShippingDirections(); // blank obj
                DropDownList       shipViaDropDown = e.Item.FindControl("ShipperDropDown") as DropDownList;
                if (shipViaDropDown != null)                                   // if i got the control
                {
                    shipInfo.ShipperId = int.Parse(shipViaDropDown.SelectedValue);
                }

                TextBox tracking = e.Item.FindControl("TrackingCode") as TextBox;
                if (tracking != null)
                {
                    shipInfo.TrackingCode = tracking.Text;
                }

                decimal price;
                TextBox freight = e.Item.FindControl("FreightCharge") as TextBox;
                if (freight != null && decimal.TryParse(freight.Text, out price))
                {
                    shipInfo.FreightCharge = price;
                }

                List <ShippedItem> goods = new List <ShippedItem>();
                GridView           gv    = e.Item.FindControl("ProductsGridView") as GridView;
                if (gv != null)
                {
                    foreach (GridViewRow row in gv.Rows)
                    {
                        // get product id and ship qty
                        short       quantity;
                        HiddenField prodId = row.FindControl("ProductId") as HiddenField;
                        TextBox     qty    = row.FindControl("ShipQuantity") as TextBox;
                        if (prodId != null && qty != null && short.TryParse(qty.Text, out quantity))
                        {
                            ShippedItem item = new ShippedItem
                            {
                                Product  = prodId.Value,
                                Quantity = quantity
                            };
                            goods.Add(item);
                        }
                    }
                }

                MessageUserControl.TryRun(() =>
                {
                    var controller = new OrderProcessingController();
                    controller.ShipOrder(orderId, shipInfo, goods);
                }, "Order Shipment Recorded", "The Products identified as shipped are recorded in the database");
            }
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Handles events that occur when a button in the Questions list view is clicked.
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateQuestionsListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //hide message user control
        MessageUserControl.Visible = false;

        //If the Edit button is clicked, show informational message
        if (e.CommandName.Equals("Edit"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The question text in the selected row can now be edited.");
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            int i = e.Item.DisplayIndex;

            //Capture and store the question text on the selected index
            TextBox questionTextBox = UpdateQuestionsListView.Items[i].FindControl("questionTextTextBox") as TextBox;
            string  questionText    = questionTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(questionText) || string.IsNullOrWhiteSpace(questionText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Question is required.");

                //highlight the question textbox that handled the error
                questionTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                //find the question Id repeater that stores the question Ids associated with the edited question text
                Repeater questionIdRepeater = UpdateQuestionsListView.Items[i].FindControl("QuestionIdListRepeater") as Repeater;

                //loop through the question Id repeater
                foreach (RepeaterItem item in questionIdRepeater.Items)
                {
                    //capture the question Id
                    int questionId = int.Parse(((Label)item.FindControl("questionIdLabel")).Text);

                    MessageUserControl.TryRun(() =>
                    {   //check if user entered invalid values
                        Utility utility = new Utility();
                        utility.checkValidString(questionText);

                        //Update the selected question(s)
                        QuestionController sysmgr = new QuestionController();
                        sysmgr.Question_Update(questionText, questionId);

                        //turn off edit mode and refresh the listview
                        UpdateQuestionsListView.EditIndex = -1;
                        UpdateQuestionsListView.DataBind();
                    }, "Success", "Question has been updated.");
                }

                //show success/error message captured by message user control's try run method
                MessageUserControl.Visible = true;

                //reset update subquestions tab
                QuestionsWithSubQuestionsDropDownList.Items.Clear();
                QuestionsWithSubQuestionsDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithSubQuestionsDropDownList.DataBind();
                QuestionsWithSubQuestionsDropDownList.Enabled = true;
                FetchSubQuestionsButton.Enabled = true;

                //reset update answers tab
                QuestionsWithAnswersDropDownList.Items.Clear();
                QuestionsWithAnswersDropDownList.Items.Add(new ListItem("Select a question...", "0"));
                QuestionsWithAnswersDropDownList.DataBind();
                QuestionsWithAnswersDropDownList.Enabled = true;
                FetchAnswersButton.Enabled = true;

                //show datapager
                DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
                pager.Visible = true;
            }
        }
        //If the Cancel button is clicked, show informational message
        else if (e.CommandName.Equals("Cancel"))
        {
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update Cancelled", "No changes to the selected question were saved.");

            //show datapager
            DataPager pager = UpdateQuestionsListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;
        }
    }
Ejemplo n.º 4
0
    /*
     * CREATED:     E. Lautner		APR 1 2018
     * MODIFIED:   C. Stanhope     APR 14 2018
     *  - changed validation to match the account_add validation
     *
     * ModifyUser_Click()
     * Gathers all given information on the page about the selected account. Sends this information to the userManager so that the account can be updated.
     *
     * PARAMETERS:
     * object sender - references the object that raised the Page_Load event
     * EventArgs e - optional class that may be passed that inherits from EventArgs (usually empty)
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * MessageUserControl.ShowSuccessMessage()
     * MessageUserControl.ShowErrorMessage()
     * UserManager.ModifyAccount()
     * UserManager.GetRoles()
     */
    protected void ModifyUser_Click(object sender, EventArgs e)
    {
        {
            sentUserName = Request.QueryString["id"];
            if (sentUserName == "" || sentUserName == null)
            {
                MessageUserControl.ShowErrorMessage("An account has not been selected. Please navigate back to the Account Search page and select an account. If error persists, please contact your administrator.");
            }

            else
            {
                //Retrieve the values from the controls
                string firstNameText = FirstNameTB.Text.Trim();
                string lastNameText  = LastNameTB.Text.Trim();
                string emailText     = EmailTB.Text.Trim();
                string authLevelText = AuthorizationLevelRolesRadioList.SelectedValue;
                int    careSiteID    = int.Parse(CareSiteDDL.Visible == false ? "0" : CareSiteDDL.SelectedValue);

                List <string> errorList = new List <string>();
                bool          isValid   = true;

                #region check if any inputs are blank
                if (string.IsNullOrWhiteSpace(firstNameText))
                {
                    errorList.Add("First Name");
                    isValid = false;
                }

                if (string.IsNullOrWhiteSpace(lastNameText))
                {
                    errorList.Add("Last Name");
                    isValid = false;
                }

                if (string.IsNullOrWhiteSpace(emailText))
                {
                    errorList.Add("Email");
                    isValid = false;
                }
                if (string.IsNullOrWhiteSpace(authLevelText))
                {
                    errorList.Add("Authorization Level");
                    isValid = false;
                }
                #endregion

                if (!isValid)
                {
                    ErrorMessagesAndValidation errMessAndVal = new ErrorMessagesAndValidation();
                    string errorMessage = errMessAndVal.ErrorList(errorList);
                    MessageUserControl.ShowInfoMessage(errorMessage);
                }
                else
                {
                    if (!emailText.Contains("@"))
                    {
                        MessageUserControl.ShowInfoMessage("Email must include an '@' symbol.");
                    }
                    else
                    {
                        if (System.Text.RegularExpressions.Regex.IsMatch(FirstNameTB.Text, @"^(?m)[A-Za-z][A-Za-z`. -]*$") && System.Text.RegularExpressions.Regex.IsMatch(LastNameTB.Text, @"^(?m)[A-Za-z][A-Za-z`. -]*$"))
                        {
                            if (int.Parse(CareSiteDDL.SelectedValue) == 0 && AuthorizationLevelRolesRadioList.SelectedValue == AuthorizationLevelRoles.User)
                            {
                                MessageUserControl.ShowInfoMessage("Authorization Level: User, must be associated with a care site");
                            }
                            else
                            {
                                try
                                {
                                    UserManager userManager  = new UserManager();
                                    var         selectedUser = userManager.FindByName(UsernameLabel.Text);
                                    var         userRoles    = userManager.GetRoles(selectedUser.Id);

                                    string userRole = string.Join("", userRoles.ToArray());

                                    string newUserName = userManager.ModifyAccount(UsernameLabel.Text, FirstNameTB.Text.Trim(), LastNameTB.Text.Trim(), EmailTB.Text.Trim(), int.Parse(CareSiteDDL.SelectedValue), userRole, AuthorizationLevelRolesRadioList.SelectedValue);
                                    if (newUserName != UsernameLabel.Text)
                                    {
                                        string resultMessage = string.Format("Update successful, new UserName is {0} ", newUserName);
                                        MessageUserControl.ShowSuccessMessage(resultMessage);
                                        UsernameLabel.Text = newUserName;
                                    }

                                    else
                                    {
                                        string resultMessage = string.Format("Update successful for user: {0}", UsernameLabel.Text);
                                        MessageUserControl.ShowSuccessMessage(resultMessage);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageUserControl.ShowErrorMessage("Update Failed. Please try again. If error persists, please contact your administrator. Error Message: " + ex.Message);
                                }
                            }
                        }
                        else
                        {
                            MessageUserControl.ShowInfoMessage("First Name and Last Name can only contain letters, dashes, apostrophes, grave accents, spaces and periods.");
                        }
                    }
                }
            }
        }
    }
        protected void ReceiveShipment_Click(object sender, EventArgs e)
        {
            var receiveditems = new List <TransactionItemPOCO>();
            var rejecteditems = new List <RejectedItemPOCO>();

            int orderid = 0;

            GridViewRow orderrow = PurchaseOrderGridView.Rows[1];

            orderid = int.Parse((orderrow.FindControl("OrderID") as Label).Text);
            MessageUserControl.TryRun(() =>
            {
                foreach (GridViewRow row in PurchaseOrderGridView.Rows)
                {
                    if (int.Parse(((row.FindControl("QuantityOutstanding") as Label).Text).ToString()) > 0)
                    {
                        if (!int.TryParse(((row.FindControl("ReceivedUnitsBox") as TextBox).Text), out int receivecheck) || receivecheck <= 0)
                        {
                            throw new BusinessRuleException("Input Error", new List <String> {
                                "Received items must be an integer number greater than zero."
                            });
                        }
                        int salvageditems = 0;

                        int itemunitsize = int.Parse(((row.FindControl("ReceivedUnitsBox") as TextBox).Text));
                        int maxorder     = int.Parse(row.Cells[2].Text);
                        string itemname  = row.Cells[1].Text;
                        int itemquantity = int.Parse(((row.FindControl("UnitLabel") as Label).Text).ToString()) * itemunitsize;

                        if (string.IsNullOrEmpty(((row.FindControl("SalvagedItemsBox") as TextBox).Text)) == false)
                        {
                            if (!int.TryParse(((row.FindControl("SalvagedItemsBox") as TextBox).Text), out int salvagedcheck) || salvagedcheck <= 0)
                            {
                                throw new BusinessRuleException("Input Error", new List <String> {
                                    "Salvaged items must be an integer number greater than zero."
                                });
                            }
                            else if (itemquantity + int.Parse(((row.FindControl("SalvagedItemsBox") as TextBox).Text)) > maxorder)
                            {
                                throw new BusinessRuleException("Input Error", new List <String> {
                                    "Total Item quantity cannot be greater than the initial item order."
                                });
                            }
                            else
                            {
                                salvageditems = int.Parse(((row.FindControl("SalvagedItemsBox") as TextBox).Text));
                                itemquantity  = itemquantity + salvageditems;
                            }
                        }

                        itemquantity = itemquantity + salvageditems;

                        if (!string.IsNullOrEmpty((row.FindControl("RejectedUnitsBox") as TextBox).Text) && !string.IsNullOrEmpty((row.FindControl("RejectedReason") as TextBox).Text))
                        {
                            if (!int.TryParse(((row.FindControl("RejectedUnitsBox") as TextBox).Text), out int rejectedcheck) || rejectedcheck <= 0)
                            {
                                throw new BusinessRuleException("Input Error", new List <String> {
                                    "Rejected items must be an integer number greater than zero."
                                });
                            }
                            else if (int.TryParse(((row.FindControl("RejectedReasons") as TextBox).Text), out int rejected))
                            {
                                throw new BusinessRuleException("Input Error", new List <String> {
                                    "Reason for rejection cannot be a number."
                                });
                            }
                            else
                            {
                                int rejectitems = int.Parse((row.FindControl("RejectedUnitsBox") as TextBox).Text);
                                string reasons  = (row.FindControl("RejectedReason") as TextBox).ToString();

                                rejecteditems.Add(new RejectedItemPOCO()
                                {
                                    ItemName     = itemname,
                                    ItemQuantity = rejectitems,
                                    Reason       = reasons
                                });
                            }
                        }

                        receiveditems.Add(new TransactionItemPOCO()
                        {
                            ItemName     = itemname,
                            ItemQuantity = itemquantity
                        });
                    }
                }
            });

            MessageUserControl.TryRun(() =>
            {
                ReceivingController sysmgr = new ReceivingController();

                sysmgr.ReceiveShipment(orderid, receiveditems, rejecteditems);
            }, "Transaction Processed", "Order Received Successfully"
                                      );


            PurchaseOrderGridView.DataBind();
            int remainingitems = 0;

            foreach (GridViewRow row in PurchaseOrderGridView.Rows)
            {
                remainingitems = remainingitems + int.Parse(((row.FindControl("QuantityOutstanding") as Label).Text).ToString());
            }

            if (remainingitems == 0)
            {
                MessageUserControl.TryRun(() => {
                    ReceivingController sysmgr = new ReceivingController();
                    sysmgr.CloseOrder(orderid);
                }, "Order Complete", "This Order will now be closed");

                Response.Redirect(Request.RawUrl);
                MessageUserControl.TryRun(() => { }, "Order Complete", "The Order was closed. Please select a new one.");
            }
        }
        protected void MoveUp_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Track Movement", "You must have a play list visible to choose tracks for movement. Select from the displayed playlist.");
                }
                else
                {
                    MoveTrackItem moveTrack      = new MoveTrackItem();
                    int           rowsSelected   = 0;
                    CheckBox      trackSelection = null;
                    //traverse the gridview control PlayList
                    //you could do this same code using a foreah()
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        //point to the checkbox control on the gridview row
                        trackSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        //test the setting of the checkbox
                        if (trackSelection.Checked)
                        {
                            rowsSelected++;
                            moveTrack.TrackID     = int.Parse((trackSelection.FindControl("TrackId") as Label).Text);
                            moveTrack.TrackNumber = int.Parse((trackSelection.FindControl("TrackNumber") as Label).Text);
                        }
                    }

                    //was a single song selected
                    switch (rowsSelected)
                    {
                    case 0:
                    {
                        MessageUserControl.ShowInfo("Track Movement", "You must select   one song to move.");
                        break;
                    }

                    case 1:
                    {
                        //rule: do not move if last song
                        if (moveTrack.TrackNumber == 1)
                        {
                            MessageUserControl.ShowInfo("Track Movement", "Song select is already the first song. Moving up not necessary.");
                        }
                        else
                        {
                            moveTrack.Direction = "up";
                            MoveTrack(moveTrack);
                        }

                        break;
                    }

                    default:
                    {
                        //more than 1
                        MessageUserControl.ShowInfo("Track Movement", "You must select only one song to move.");
                        break;
                    }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected void OrderDetailsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            OrderDetailsController controller = new OrderDetailsController();
            int vendorId = int.Parse(VendorDDL.SelectedValue);

            if (e.CommandName.Equals("Refresh"))
            {
                int     OrderDetailID = int.Parse(e.CommandArgument.ToString());
                int     qty           = 0;
                decimal unitcost      = 0;
                decimal perItemCost   = 0;
                decimal unitSize      = 0;
                Label   yourlabel     = null;

                for (int rowIndex = 0; rowIndex < OrderDetailsGridView.Rows.Count; rowIndex++)
                {
                    if ((OrderDetailsGridView.Rows[rowIndex].FindControl("lblOrderDetailID") as Label).Text == e.CommandArgument.ToString())
                    {
                        qty = int.Parse((OrderDetailsGridView.Rows[rowIndex].FindControl("txtQuantity") as TextBox).Text);

                        //string z = (OrderDetailsGridView.Rows[rowIndex].FindControl("txtUnitCost") as TextBox).Text;
                        //string zRemove = z.Remove(0, 0);
                        unitcost = decimal.Parse((OrderDetailsGridView.Rows[rowIndex].FindControl("txtUnitCost") as TextBox).Text);

                        string x       = (OrderDetailsGridView.Rows[rowIndex].FindControl("lblPerItemCost") as Label).Text;
                        string xRemove = x.Remove(0, 1);
                        perItemCost = decimal.Parse(xRemove);

                        string y       = (OrderDetailsGridView.Rows[rowIndex].FindControl("lblUnitSize") as Label).Text;
                        string yRemove = y.Remove(2);
                        unitSize = decimal.Parse(yRemove);


                        // For the warning message


                        yourlabel = (OrderDetailsGridView.Rows[rowIndex].FindControl("lblCostWarning") as Label);
                        //bind your label to data here
                    }
                }
                if (qty <= 0)
                {
                    MessageUserControl.ShowInfo("Quantity can not be a negative number");
                }
                else if (perItemCost > (unitcost / unitSize))
                {
                    MessageUserControl.ShowInfo("Per-item cost can not be greater than selling price");
                    yourlabel.Visible = true;
                    CalculateTotal(controller, vendorId);
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        controller.Quantity_Refresh(OrderDetailID, qty, unitcost);
                        List <ListVendorOrders> datainfo = controller.Get_Active_Order(vendorId);
                        OrderDetailsGridView.DataSource  = datainfo;
                        OrderDetailsGridView.DataBind();
                        CalculateTotal(controller, vendorId);
                    }, "Refreshing", "Item Quantity Updated");
                }
            }
            else
            {
                int OrderDetailID = int.Parse(e.CommandArgument.ToString());
                MessageUserControl.TryRun(() =>
                {
                    controller.Delete_ProductItem(OrderDetailID);

                    List <ListVendorOrders> datainfo = controller.Get_Active_Order(vendorId);
                    OrderDetailsGridView.DataSource  = datainfo;
                    OrderDetailsGridView.DataBind();
                    CalculateTotal(controller, vendorId);
                }, "Deleting Product", "Item Has been Removed from Order");
            }
        }
Ejemplo n.º 8
0
        protected void MoveUp_Click(object sender, EventArgs e)
        {
            List <string> reasons = new List <string>();

            //is there a playlist?
            //    no msg
            if (PlayList.Rows.Count == 0)
            {
                reasons.Add("There is no playlist present. Fetch your playlist.");
            }
            //is there a playlist name??
            //    no msg
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                reasons.Add("You must have a playlist name.");
            }
            //traverse playlist to collect selected row(s)
            //> 1 row selected
            //    bad msg
            int      trackid           = 0;
            int      tracknumber       = 0;
            int      rowsSelected      = 0;
            CheckBox playlistselection = null;

            for (int rowindex = 0; rowindex < PlayList.Rows.Count; rowindex++)
            {
                //access the checkbox control on the indexed GridViewRow
                //set the CheckBox pointer to this checkbox control
                playlistselection = PlayList.Rows[rowindex].FindControl("Selected") as CheckBox;
                if (playlistselection.Checked)
                {
                    //increase selected number of rows
                    rowsSelected++;
                    //gather the data needed for the BLL call
                    trackid     = int.Parse((PlayList.Rows[rowindex].FindControl("TrackID") as Label).Text);
                    tracknumber = int.Parse((PlayList.Rows[rowindex].FindControl("TrackNumber") as Label).Text);
                }
            }
            if (rowsSelected != 1)
            {
                reasons.Add("Select only one track to move.");
            }
            //check if last track
            //    bad msg
            if (tracknumber == 1)
            {
                reasons.Add("First track cannot be moved up");
            }
            //validation good
            if (reasons.Count == 0)
            {
                //   yes: move track
                MoveTrack(trackid, tracknumber, "up");
            }
            else
            {
                //    no: display all errors
                MessageUserControl.TryRun(() => {
                    throw new BusinessRuleException("Track Move Errors:", reasons);
                });
            }
        }
Ejemplo n.º 9
0
        protected void Refund_Click(object sender, EventArgs e)
        {
            string  userName = User.Identity.Name;
            decimal subtotal = 0;
            decimal tax      = 0;
            decimal total    = 0;


            List <RefundDetail> newDetail = new List <RefundDetail>();
            RefundDetail        newRow    = null;
            CheckBox            selection = null;
            int error = 0;

            for (int rowIndex = 0; rowIndex < RefundInvoiceGridView.Rows.Count; rowIndex++)
            {
                selection = RefundInvoiceGridView.Rows[rowIndex].FindControl("RefundCheckBox") as CheckBox;
                if (!selection.Checked)
                {
                    MessageUserControl.ShowInfo("please select refund product and enter a refund reason");
                }
                else
                {
                    if (string.IsNullOrEmpty((RefundInvoiceGridView.Rows[rowIndex].FindControl("ReasonTextBox") as TextBox).Text))
                    {
                        MessageUserControl.ShowInfo("Please  enter a refund reason.");
                        error = 1;
                    }
                    else
                    {
                        newRow               = new RefundDetail();
                        newRow.Product       = (RefundInvoiceGridView.Rows[rowIndex].FindControl("ProductLabel") as Label).Text;
                        newRow.Qty           = int.Parse((RefundInvoiceGridView.Rows[rowIndex].FindControl("QtyLabel") as Label).Text);
                        newRow.Price         = decimal.Parse((RefundInvoiceGridView.Rows[rowIndex].FindControl("PriceLabel") as Label).Text);
                        newRow.Amount        = decimal.Parse((RefundInvoiceGridView.Rows[rowIndex].FindControl("AmountLabel") as Label).Text);
                        newRow.RestockCharge = decimal.Parse((RefundInvoiceGridView.Rows[rowIndex].FindControl("RestockChargeLabel") as Label).Text);
                        newRow.Reason        = (RefundInvoiceGridView.Rows[rowIndex].FindControl("ReasonTextBox") as TextBox).Text;
                        newDetail.Add(newRow);

                        subtotal = subtotal + newRow.Amount - newRow.RestockCharge;
                        tax      = subtotal * (decimal)0.05;
                        total    = subtotal + tax;
                    }
                }
            }


            int refunded = 0;

            if (error == 0)
            {
                foreach (var exists in newDetail)
                {
                    int prodID        = Get_ProductID(exists.Product);
                    int originvoiceID = int.Parse(InvocieNumber.Text);
                    refunded = CheckForRefunded(originvoiceID, prodID);
                    if (refunded == 1)
                    {
                    }
                    else
                    {
                        MessageUserControl.TryRun(() =>
                        {
                            SubtotalTextBox.Text = string.Format("${0:#,#.00}", subtotal.ToString());
                            GSTTextBox.Text      = string.Format("${0:#,#.00}", tax.ToString());
                            TotalTextBox.Text    = string.Format("${0:C}", total.ToString());


                            List <InvoiceDetailInfo> alldetaill = new List <InvoiceDetailInfo>();
                            List <StoreRefundInfo> refundlist   = new List <StoreRefundInfo>();

                            foreach (var item in newDetail)
                            {
                                alldetaill.Add(new InvoiceDetailInfo
                                {
                                    ProductID = Get_ProductID(item.Product),
                                    Quantity  = item.Qty,
                                });
                            }

                            foreach (var items in newDetail)
                            {
                                refundlist.Add(new StoreRefundInfo
                                {
                                    OriginalInvoiceID = int.Parse(InvocieNumber.Text),
                                    ProductID         = Get_ProductID(items.Product),
                                    Reason            = items.Reason,
                                }
                                               );
                            }

                            List <InvoiceInfo> NewInvoice = new List <InvoiceInfo>();

                            NewInvoice.Add(new InvoiceInfo
                            {
                                EmployeeID  = Get_EmpID(userName),
                                InvoiceDate = DateTime.Now,
                                SubTotal    = (subtotal * -1),
                                GST         = (tax * -1),
                                Total       = (total * -1),
                            });


                            RefundRequired request = new RefundRequired
                            {
                                RequiredInvoice = NewInvoice,
                                ReuquiredDetail = alldetaill,
                                RequiredStore   = refundlist
                            };

                            var controller = new StoreRefundController();
                            controller.CreateRefund(request);



                            foreach (GridViewRow row in RefundInvoiceGridView.Rows)
                            {
                                var checkbox  = row.FindControl("RefundCheckBox") as CheckBox;
                                var reasonbox = row.FindControl("ReasonTextBox") as TextBox;

                                checkbox.Enabled  = false;
                                reasonbox.Enabled = false;
                            }
                        }, "Refund successful", "Selected products have been refunded.");

                        RefundOrder.Enabled       = false;
                        RefundInvoiceTextBox.Text = getinvocieid().ToString();
                    }
                }
            }
            else
            {
                MessageUserControl.ShowInfo("one of the product is not enter a reason ");
            }
        }
Ejemplo n.º 10
0
    protected void Results_Lbtn_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            List <string> allCourseList = new List <string>();
            List <string> repeatCourse  = new List <string>();
            foreach (GridViewRow theRow in GV_EnterCourseMarks.Rows)
            {
                int sameCourseCount = 0;

                DropDownList DL_Course = (DropDownList)theRow.FindControl("DL_Course");

                allCourseList.Add(DL_Course.SelectedValue);

                foreach (string theCourse in allCourseList)
                {
                    if (DL_Course.SelectedValue == theCourse)
                    {
                        sameCourseCount += 1;
                    }
                }
                if (sameCourseCount >= 2)
                {
                    repeatCourse.Add(DL_Course.SelectedValue);
                }
            }

            if (repeatCourse.Count == 0)
            {
                if (DL_CredentialTypes.SelectedValue == "Degree")
                {
                    RP_Degree_ProfileResults.DataBind();
                    RP_ProfileResults.Visible        = false;
                    RP_Degree_ProfileResults.Visible = true;
                    LB_ProgramCount.Text             = "Total Programs Matched: (" + RP_Degree_ProfileResults.Items.Count + ")";
                }
                else
                {
                    RP_ProfileResults.DataBind();
                    RP_ProfileResults.Visible        = true;
                    RP_Degree_ProfileResults.Visible = false;
                    LB_ProgramCount.Text             = "Total Programs Matched: (" + RP_ProfileResults.Items.Count + ")";
                }

                Step4.Visible          = false;
                Results_Header.Visible = true;
                Results.Visible        = true;
                wizard.Visible         = false;
                TryAgain.Visible       = true;
            }
            else
            {
                throw new Exception("You cannot enter the Same Course at the same time.");
            }
        });
        MessageUserControl.TryRun((ProcessRequest)CompareMarks);
        foreach (RepeaterItem myCertainProgram in RP_ProfileResults.Items)
        {
            var lb_MyProgramID = myCertainProgram.FindControl("LB_ProgramID") as Label;
            var btn_MyMoreInfo = myCertainProgram.FindControl("MoreInfo_Lbtn") as LinkButton;

            if (allEnteredCourseMarks.Equals(",;"))
            {
                allEnteredCourseMarks = "";
            }

            btn_MyMoreInfo.OnClientClick =
                "window.open('ViewProgram.aspx?programID=" + lb_MyProgramID.Text +
                "&allEnteredCourseMarks=" + allEnteredCourseMarks + "')";
        }
        foreach (RepeaterItem myCertainDegree in RP_Degree_ProfileResults.Items)
        {
            var lb_MyDegreeID        = myCertainDegree.FindControl("LB_DegreeID") as Label;
            var btn_MyDegreeMoreInfo = myCertainDegree.FindControl("MoreInfo_Lbtn") as LinkButton;

            if (allEnteredCourseMarks.Contains(",;"))
            {
                allEnteredCourseMarks = "";
            }

            btn_MyDegreeMoreInfo.OnClientClick =
                "window.open('ViewProgram.aspx?programID=" + lb_MyDegreeID.Text +
                "&allEnteredCourseMarks=" + allEnteredCourseMarks + "')";
        }
    }
Ejemplo n.º 11
0
    /*
     * CREATED:     T.J. Blakely		MAR 19 2018
     *
     * ProcessReport()
     * This method validates all user input & filters, and then processes the report.
     *
     * PARAMETERS:
     * None
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * ControlValidation()
     * GetData()
     * MessageUserControl.ShowInfoMessage()
     */
    protected void ProcessReport()
    {
        // list to hold error msgs
        List <string> errors = new List <string>();

        // local variable declaration
        int questionID;

        if (QuestionDDL.SelectedValue != "")
        {
            questionID = int.Parse(QuestionDDL.SelectedValue);
        }
        else
        {
            questionID = 0;
        }
        List <string> unitIDs = new List <string>();
        List <string> respondentTypes = new List <string>();
        List <string> genders = new List <string>();
        List <string> ages = new List <string>();
        DateTime      startDate = new DateTime(), endDate = new DateTime();

        // regex to check date fields
        string pattern = @"^$|^(0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])[/][0-9]{4}$";
        Regex  reg = new Regex(pattern);

        // finding and validating page controls
        if (CareSiteDDL.SelectedValue != "")
        {
            ControlValidation(UnitRepeater, unitIDs, "HiddenUnitID");
        }
        ControlValidation(RespondentTypeRepeater, respondentTypes, "HiddenRespondentTypeID");
        ControlValidation(GenderRepeater, genders, "HiddenGenderID");
        ControlValidation(AgeGroupRepeater, ages, "HiddenAgeGroupID");

        // care site & unit validation
        if (CareSiteDDL.SelectedValue != "" && unitIDs.Count == 0)
        {
            errors.Add("Please select at least one unit.");
        }

        // date validation
        // checking if the data matches the regex
        if (!reg.IsMatch(dateStart.Text) || !reg.IsMatch(dateEnd.Text))
        {
            errors.Add("Dates must be in mm/dd/yyyy format.");
        }
        else
        {
            // checking if the data can be parsed
            if (dateStart.Text != "" && !DateTime.TryParse(dateStart.Text, out startDate))
            {
                errors.Add("Start date must be in mm/dd/yyyy format.");
            }
            if (dateEnd.Text != "" && !DateTime.TryParse(dateEnd.Text, out endDate))
            {
                errors.Add("End date must be in mm/dd/yyyy format.");
            }
            // checking if the dates are valid
            if (startDate > DateTime.Today || endDate > DateTime.Today)
            {
                errors.Add("Please select dates that are on or before today's date.");
            }
            if (dateStart.Text != "" && dateEnd.Text != "" && startDate > endDate)
            {
                errors.Add("Please ensure that the provided end date occurs after or on the same day as the provided start date.");
            }
            else
            {
                if (dateStart.Text != "" && dateEnd.Text == "")
                {
                    dateEnd.Text = DateTime.Today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
                    endDate      = DateTime.Today;
                }
            }
        }

        // respondent type validation
        if (respondentTypes.Count == 0)
        {
            errors.Add("Please select at least one respondent type to filter by.");
        }

        // gender validation
        if (genders.Count == 0)
        {
            errors.Add("Please select at least one gender to filter by.");
        }

        // age group validation
        if (ages.Count == 0)
        {
            errors.Add("Please select at least one age group to filter by.");
        }

        // question validation
        if (questionID == 0)
        {
            errors.Add("Please select a question from the drop-down list.");
        }

        // check if there were errors found; if not, process the report
        if (errors.Count == 1)
        {
            MessageUserControl.ShowInfoMessage(errors[0]);
            ReportViewer1.Visible = false;
        }
        else
        {
            if (errors.Count > 1)
            {
                MessageUserControl.ShowInfoList("Please address the following errors and try again:", errors);
                ReportViewer1.Visible = false;
            }
            else // all data is assumed valid, create dataset
            {
                // these statements are to clear filters lists if all are selected; makes the query neater
                if (dateEnd.Text == "")
                {
                    dateEnd.Text = DateTime.Today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                if (respondentTypes.Count == RespondentTypeRepeater.Items.Count)
                {
                    respondentTypes.Clear();
                }

                if (ages.Count == AgeGroupRepeater.Items.Count)
                {
                    ages.Clear();
                }

                if (genders.Count == GenderRepeater.Items.Count)
                {
                    genders.Clear();
                }

                DataSet dt = GetData(questionID, unitIDs, respondentTypes, genders, ages, startDate, endDate);

                // checking if 0 surveys are found - display "no data found"
                int count = 0;
                foreach (DataRow row in dt.Tables[0].Rows)
                {
                    count += int.Parse(row.ItemArray[2].ToString());
                }

                if (count == 0)
                {
                    MessageUserControl.ShowInfoMessage("No data was found matching the entered search criteria.");
                    ReportViewer1.Visible = false;
                }
                else // if you get here, the filters are valid! run the report.
                {
                    ReportViewer1.Visible = true;
                    ReportParameter  param = new ReportParameter("QuestionID", QuestionDDL.SelectedItem.Text.Split(':')[0]);
                    ReportDataSource rds   = new ReportDataSource("TrendSource", dt.Tables[0]);
                    ReportViewer1.LocalReport.DataSources.Clear();
                    ReportViewer1.LocalReport.ReportPath = "Reports/Trend.rdlc";
                    ReportViewer1.LocalReport.SetParameters(param);
                    ReportViewer1.LocalReport.DataSources.Add(rds);
                    ReportViewer1.LocalReport.DisplayName = "Trends_" + QuestionDDL.SelectedItem.Text.Split(':')[0] + "_" + DateTime.Now.ToString("MMMddyyyy_HHmm");
                    ReportViewer1.LocalReport.Refresh();
                }
            }
        }
    }
Ejemplo n.º 12
0
    protected void CompareMarks()
    {
        //GridView userCourseMarks_GV = new GridView();
        //Repeater dbCourseMarks_RP = new Repeater();

        GridView userCourseMarks_GV = GV_EnterCourseMarks as GridView;
        Repeater dbCourseMarks_RP   = RP_ProfileResults as Repeater;

        //Get GV Row Data
        foreach (GridViewRow theRow in userCourseMarks_GV.Rows)
        {
            //Setup variables for GV data
            var myGVCourseControl = theRow.FindControl("DL_Course") as DropDownList;
            var myGVMarksControl  = theRow.FindControl("TB_EnterMarks") as TextBox;

            //Pass course and marks to next page
            //allEnteredCourseMarksList.Add(myGVCourseControl.SelectedItem.ToString() + "," + myGVMarksControl.Text + ";");
            //allEnteredCourseMarksList.ToString();

            string myGVCourse = "No Course";
            int    myGVMarks  = 101;

            //Get selected course from GV
            if (myGVCourseControl.SelectedIndex != 0)
            {
                myGVCourse          = myGVCourseControl.SelectedValue;
                LB_EnterCourse.Text = myGVCourse;
            }
            else
            {
                MessageUserControl.ShowInfo("A course field requires a selection.");
                myGVCourseControl.SelectedIndex = 0;
                myGVMarksControl.Text           = "";
            }

            //Get entered marks from GV
            if (!string.IsNullOrEmpty(myGVMarksControl.Text))
            {
                myGVMarks = int.Parse(myGVMarksControl.Text.ToString());
            }
            else
            {
                MessageUserControl.ShowInfo("A grade field must be filled out.");
                myGVCourseControl.SelectedIndex = 0;
                myGVMarksControl.Text           = "";
            }

            //add entered courses and marks as a query string
            allEnteredCourseMarks += myGVCourseControl.SelectedValue.ToString() + "," + myGVMarksControl.Text + ";";

            LB_EnterMarks.Text = myGVMarks.ToString();

            //Get Parent Repeater Data
            foreach (RepeaterItem theItem in dbCourseMarks_RP.Items)
            {
                var Upgrading_Lbtn          = theItem.FindControl("Upgrading_Lbtn") as LinkButton;
                var myProgramNameControl    = theItem.FindControl("ProgramName") as Label;
                var MoreInfo_Lbtn           = theItem.FindControl("MoreInfo_Lbtn") as LinkButton;
                var LB_NoEntranceReqMessage = theItem.FindControl("LB_NoEntranceReqMessage") as Label;
                //var ReuiredTitle_Original = theItem.FindControl("ReuiredTitle_Original") as Label;

                var StatusHeader = theItem.FindControl("StatusHeader") as Label;
                var EntReqHeader = theItem.FindControl("EntReqHeader") as Label;

                //for first child repeater
                var rp_Controls = theItem.FindControl("RP_CourseMarks") as Repeater;

                //for 2nd child repeater
                var rp_MyProgramDetail = theItem.FindControl("RP_DetailCourseMarks") as Repeater;

                //for 2nd child repeater
                var rp_MySuggestion    = theItem.FindControl("RP_UnqualifiedCourse") as Repeater;
                var mySuggestionTable  = theItem.FindControl("SuggestionTable") as Table;
                var myOrgRequiredTitle = theItem.FindControl("ReuiredTitle_Original") as Label;
                var myRequiredTitle    = theItem.FindControl("RequiredTitle") as Label;
                var myEnteredTitle     = theItem.FindControl("EnteredTitle") as Label;

                List <string> qualifiedList = new List <string>();

                //Get child Repeater Data
                foreach (RepeaterItem theChildItem in rp_Controls.Items)
                {
                    // setup repeater child item as instance
                    var courseControl       = theChildItem.FindControl("LB_Results_CourseID") as Label;
                    var marksControl        = theChildItem.FindControl("LB_Results_Marks") as Label;
                    var subjectCourse       = theChildItem.FindControl("LB_Results_SubjectName") as Label;
                    var LB_UserEnterMessage = theChildItem.FindControl("LB_UserEnterMessage") as Label;

                    //get data from repeater items
                    string rp_TheCourse = courseControl.Text.ToString();
                    string rp_Marks     = marksControl.Text.ToString();



                    //assign marks that user enters in
                    int rp_TheMarks = int.Parse(marksControl.Text.ToString());

                    // Compare course and marks
                    if (myGVCourse.Equals(rp_TheCourse))
                    {
                        if (myGVMarks < rp_TheMarks)
                        {
                            Upgrading_Lbtn.Visible        = true;
                            subjectCourse.ForeColor       = ColorTranslator.FromHtml("#ff3300");
                            subjectCourse.Font.Bold       = true;
                            marksControl.ForeColor        = ColorTranslator.FromHtml("#ff3300");
                            marksControl.Font.Bold        = true;
                            LB_UserEnterMessage.Text      = "<span class='glyphicon glyphicon-ban-circle'></span>";
                            LB_UserEnterMessage.ForeColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            subjectCourse.ForeColor       = ColorTranslator.FromHtml("#009900");
                            subjectCourse.Font.Bold       = true;
                            marksControl.ForeColor        = ColorTranslator.FromHtml("#009900");
                            marksControl.Font.Bold        = true;
                            LB_UserEnterMessage.Text      = "<span class='glyphicon glyphicon-ok'></span>";
                            LB_UserEnterMessage.ForeColor = System.Drawing.Color.Green;
                        }

                        qualifiedList.Add(LB_UserEnterMessage.Text);
                    }

                    if (LB_UserEnterMessage.Text == "")
                    {
                        LB_UserEnterMessage.Text = "-";
                    }

                    LB_NoEntranceReqMessage.Visible = false;

                    EntReqHeader.Visible = true;
                    StatusHeader.Visible = true;

                    //ReuiredTitle_Original.Visible = true;
                }
            }
        }
    }
Ejemplo n.º 13
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            var controller = new SalesController();
            var qty        = int.Parse(QtyTextBox.Text);
            var existing   = SaleCartItemsGridView.TemplateControl.FindControl("ProductLabel") as Label;


            if (CategoryList.SelectedIndex == 0)
            {
                MessageUserControl.ShowInfo("please select a product");
            }
            else
            {
                if (qty <= 0)
                {
                    var product = controller.GetProduct(int.Parse(productList.SelectedValue));
                    QtyTextBox.Text = 1.ToString();

                    if (existing == null)
                    {
                        var item = new SaleCartItem
                        {
                            ProductID   = product.ProductID,
                            ProductName = product.ItemName,
                            Quantity    = int.Parse(QtyTextBox.Text),
                            Price       = product.ItemPrice,
                            Amount      = product.ItemPrice * int.Parse(QtyTextBox.Text),
                        };

                        var salecart = Loopform();
                        salecart.Add(item);

                        SaleCartItemsGridView.DataSource = salecart;
                        SaleCartItemsGridView.DataBind();
                        MessageUserControl.ShowInfo("Add item to cart success ");
                        MoneyTotal();
                    }
                    else
                    {
                        MessageUserControl.ShowInfo("item already in cart ");
                    }
                }
                else
                {
                    var product = controller.GetProduct(int.Parse(productList.SelectedValue));
                    var item    = new SaleCartItem
                    {
                        ProductID   = product.ProductID,
                        ProductName = product.ItemName,
                        Quantity    = qty,
                        Price       = product.ItemPrice,
                        Amount      = product.ItemPrice * qty,
                    };

                    var salecart = Loopform();
                    salecart.Add(item);

                    SaleCartItemsGridView.DataSource = salecart;
                    SaleCartItemsGridView.DataBind();
                    MessageUserControl.ShowInfo("Add item to cart success ");
                    MoneyTotal();
                }
            }
        }
Ejemplo n.º 14
0
        protected void PayButton_Click(object sender, EventArgs e)
        {
            var form = Loopform();

            SaleCartItemsGridView.DataSource = form;
            SaleCartItemsGridView.DataBind();
            MoneyTotal();



            string userName   = User.Identity.Name;
            int    employeeID = Get_EmpID(userName);
            List <NewInvoiceDetail> invoiceRows = new List <NewInvoiceDetail>();
            List <string>           reasons     = new List <string>();



            NewInvoiceDetail newDetail = null;

            foreach (GridViewRow item in this.SaleCartItemsGridView.Rows)
            {
                newDetail           = new NewInvoiceDetail();
                newDetail.ProductID = Get_ProductID((item.FindControl("ProductLabel") as Label).Text);
                newDetail.Quantity  = int.Parse((item.FindControl("QuantityTextBox") as TextBox).Text);

                SalesController controller = new SalesController();


                newDetail.Price = Get_ProductPrice(Get_ProductID((item.FindControl("ProductLabel") as Label).Text));
                invoiceRows.Add(newDetail);
            }
            if (SubtotalTextBox.Text == "$0")
            {
                MessageUserControl.ShowInfo("please add some product");
            }
            else
            {
                NewInvoice invoice = new NewInvoice();
                invoice.EmployeeID  = employeeID;
                invoice.InvoiceDate = DateTime.Now;
                invoice.Subtotal    = decimal.Parse(SubtotalTextBox.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.Number);
                invoice.GST         = decimal.Parse(GSTTextBox.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.Number);
                invoice.Total       = decimal.Parse(TotalTextBox.Text, NumberStyles.AllowCurrencySymbol | NumberStyles.Number);
                invoice.NewDetails  = invoiceRows;

                //pass to BLL
                SaleCartItemsController controller = new SaleCartItemsController();
                int rows = controller.Pay_ForCart(invoice);
                MessageUserControl.ShowInfo("Payment successful!");

                foreach (GridViewRow loop in this.SaleCartItemsGridView.Rows)
                {
                    var qty           = loop.FindControl("QuantityTextBox") as TextBox;
                    var Refreshbutton = loop.FindControl("RefreshButton") as ImageButton;
                    var deletebutton  = loop.FindControl("ClearItemButton") as ImageButton;
                    Refreshbutton.Enabled = false;
                    deletebutton.Enabled  = false;
                    qty.Enabled           = false;
                }
                AddButton.Enabled    = false;
                PayButton.Enabled    = false;
                QtyTextBox.Enabled   = false;
                CategoryList.Enabled = false;
                productList.Enabled  = false;

                NewIdBox.Text = Get_NEW_Invocieid().ToString();
            }
        }
Ejemplo n.º 15
0
    protected void SubmitProgram_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            // BUILD OBJECTS AND UPDATE BASED ON PROGRAM TYPE

            //Declare variables for error handling
            Uri tempUrl;
            int temp;
            string errorList = "";

            if (InitialCredential.SelectedValue == "Certificate")
            {
                //Validate non-string variables
                //Po
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    //Po
                    if ((int.Parse(ProgramLength.Text.Trim())) < 0 || (int.Parse(ProgramLength.Text.Trim())) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                //Po
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }
                PathwaysController controller = new PathwaysController();



                //verify the URL does not exist
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    //Po
                    bool checkURL = controller.CheckDipCertUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                //Po
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    //Po
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }
                //validate field length
                if (EntReqDetail.Text.Trim().Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }

                byte competitiveAdvantage;
                result = byte.TryParse(CompetitiveAdv.Text.Trim(), out competitiveAdvantage);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole numbers greater than zero only). \\n";
                }

                if (competitiveAdvantage < 0 || competitiveAdvantage > 100)
                {
                    errorList += "- Please enter a numeric value between 1 - 99. \\n";
                }

                //populate certificate
                DiplomaCertificate certificate = new DiplomaCertificate()
                {
                    ProgramID                 = int.Parse(ProgramID.Text),
                    ProgramName               = ProgramName.Text.Trim(),
                    ProgramLength             = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    EntranceRequirementDetail = EntReqDetail.Text,
                    CompetitveAdvantage       = competitiveAdvantage,
                    ProgramLink               = ProgramLink.Text.Trim(),
                    Activated                 = Activated.Checked,
                    WorkOutdoors              = WorkOutdoors.Checked,
                    ShiftWork                 = ShiftWork.Checked,
                    WorkTravel                = Travel.Checked,
                    CredentialType            = false,
                    CategoryID                = int.Parse(CategoryList.SelectedValue)
                };
                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                // PathwaysController controller = new PathwaysController();
                controller.CertDiploma_Update(certificate);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Certificate program has been updated.');</script>");
            }
            else if (InitialCredential.SelectedValue == "Diploma")
            {
                //Validate non-string variables
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(ProgramLength.Text)) < 0 || (int.Parse(ProgramLength.Text)) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }
                PathwaysController controller = new PathwaysController();

                //verify the URL does not exist
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    bool checkURL = controller.CheckDipCertUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }
                //validate field length
                if (EntReqDetail.Text.Trim().Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }

                byte competitiveAdvantage;
                result = byte.TryParse(CompetitiveAdv.Text.Trim(), out competitiveAdvantage);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole numbers greater than zero only). \\n";
                }

                if (competitiveAdvantage < 0 || competitiveAdvantage > 100)
                {
                    errorList += "- Please enter a numeric value between 1 - 99. \\n";
                }

                //populate diploma
                DiplomaCertificate diploma = new DiplomaCertificate()
                {
                    ProgramID                 = int.Parse(ProgramID.Text),
                    ProgramName               = ProgramName.Text.Trim(),
                    ProgramLength             = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    EntranceRequirementDetail = EntReqDetail.Text.Trim(),
                    CompetitveAdvantage       = competitiveAdvantage,
                    ProgramLink               = ProgramLink.Text.Trim(),
                    Activated                 = Activated.Checked,
                    WorkOutdoors              = WorkOutdoors.Checked,
                    ShiftWork                 = ShiftWork.Checked,
                    WorkTravel                = Travel.Checked,
                    CredentialType            = true,
                    CategoryID                = int.Parse(CategoryList.SelectedValue)
                };
                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                //PathwaysController controller = new PathwaysController();
                controller.CertDiploma_Update(diploma);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Diploma program has been updated.');</script>");
            }
            else if (InitialCredential.SelectedValue == "Degree")
            {
                //Validate non-string variables
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(ProgramLength.Text.Trim())) < 0 || (int.Parse(ProgramLength.Text)) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }

                PathwaysController controller = new PathwaysController();
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    //verify the URL does not exist
                    bool checkURL = controller.CheckDegUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }

                //populate degree
                Degree degree = new Degree()
                {
                    DegreeID     = int.Parse(ProgramID.Text),
                    DegreeName   = ProgramName.Text.Trim(),
                    DegreeLength = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    DegreeLink   = ProgramLink.Text.Trim(),
                    Activated    = Activated.Checked,
                    WorkOutdoors = WorkOutdoors.Checked,
                    ShiftWork    = ShiftWork.Checked,
                    WorkTravel   = Travel.Checked,
                    CategoryID   = int.Parse(CategoryList.SelectedValue)
                };

                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                //PathwaysController controller = new PathwaysController();
                controller.Degree_Update(degree);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Degree program has been updated.');</script>");
            }
            else
            {
            }
        });
    }
Ejemplo n.º 16
0
        protected void ShoppingCartList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "remove")
            {
                string username = User.Identity.Name;
                int    itemid   = int.Parse(e.CommandArgument.ToString());
                int    employeeid;

                if (ShoppingCartList.Items.Count == 0)
                {
                    MessageUserControl.ShowInfo("Warning", "You have clear the shopping cart.");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                        EmployeeInfo info             = secmgr.User_GetEmployee(username);
                        employeeid = info.EmployeeID;
                        ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                        sysmgr.DeleteShoppingItems(employeeid, itemid);

                        List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                        ShoppingCartList.DataSource       = infos;
                        notificationIcon.Value            = infos.Count.ToString();
                        ShoppingCartList.DataBind();
                        totalLabel.DataBind();

                        refresh_totallabel();
                    }, "Removed", $"Item(s) {itemid} have been removed");
                }
            }
            else if (e.CommandName == "refresh")
            {
                string username = User.Identity.Name;
                int    itemid   = int.Parse(e.CommandArgument.ToString());
                int    employeeid;
                int    quantity = int.Parse((e.Item.FindControl("QuantityLabel") as TextBox).Text);

                MessageUserControl.TryRun(() =>
                {
                    ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                    EmployeeInfo info             = secmgr.User_GetEmployee(username);
                    employeeid = info.EmployeeID;
                    ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                    sysmgr.Update_RefreshCart(employeeid, itemid, quantity);

                    List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                    ShoppingCartList.DataSource       = infos;
                    notificationIcon.Value            = infos.Count.ToString();
                    ShoppingCartList.DataBind();
                    totalLabel.DataBind();

                    refresh_totallabel();
                }, "Updated", $"Item(s) {itemid} have been updated");
            }
            else
            {
                MessageUserControl.ShowInfo("Glad you found this error, cauz I don't even know what should I call this error.");
            }
        }
Ejemplo n.º 17
0
    protected void ShowUpdateFields_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            //POPULATE FIELDS BASED ON SELECTION
            if (InitialCredential.SelectedValue == "Certificate")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible       = true;
                SubmitProgram.Visible          = true;
                DiplomaCertificate certificate = new DiplomaCertificate();
                PathwaysController controller  = new PathwaysController();


                certificate = controller.CertificateProgram_byID(int.Parse(CertificateList.SelectedValue));

                //Split string before populating form
                programLength = certificate.ProgramLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = certificate.ProgramID.ToString();
                ProgramName.Text               = certificate.ProgramName;
                CategoryList.SelectedValue     = certificate.CategoryID.ToString();
                CredentialType.Text            = "Certificate";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = certificate.ProgramLink;
                Activated.Checked              = certificate.Activated;
                WorkOutdoors.Checked           = certificate.WorkOutdoors;
                ShiftWork.Checked              = certificate.ShiftWork;
                Travel.Checked                 = certificate.WorkTravel;
                CompetitiveAdv.Text            = certificate.CompetitveAdvantage.ToString();
                EntReqDetail.Text              = certificate.EntranceRequirementDetail;

                DegreePathListView.Visible     = false;
                pathwaysheading_toggle.Visible = false;
                entrance_req.Visible           = true;
                EntReqListView.Visible         = true;
                DiplomaEntReqList.Visible      = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = certificate.ProgramLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = certificate.ProgramName;
            }

            else if (InitialCredential.SelectedValue == "Diploma")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible   = true;
                SubmitProgram.Visible      = true;
                DiplomaCertificate diploma = new DiplomaCertificate();

                PathwaysController controller = new PathwaysController();

                diploma = controller.DiplomaProgram_byID(int.Parse(DiplomaList.SelectedValue));

                //Split string before populating form
                programLength = diploma.ProgramLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = diploma.ProgramID.ToString();
                ProgramName.Text               = diploma.ProgramName;
                CategoryList.SelectedValue     = diploma.CategoryID.ToString();
                CredentialType.Text            = "Diploma";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = diploma.ProgramLink;
                Activated.Checked              = diploma.Activated;
                WorkOutdoors.Checked           = diploma.WorkOutdoors;
                ShiftWork.Checked              = diploma.ShiftWork;
                Travel.Checked                 = diploma.WorkTravel;
                CompetitiveAdv.Text            = diploma.CompetitveAdvantage.ToString();
                EntReqDetail.Text              = diploma.EntranceRequirementDetail;

                entrance_req.Visible           = true;
                EntReqListView.Visible         = false;
                DiplomaEntReqList.Visible      = true;
                DiplomaPathListView.Visible    = true;
                pathwaysheading_toggle.Visible = true;
                DegreePathListView.Visible     = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = diploma.ProgramLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = diploma.ProgramName;
            }
            else if (InitialCredential.SelectedValue == "Degree")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible = true;
                SubmitProgram.Visible    = true;
                Degree degree            = new Degree();

                PathwaysController controller = new PathwaysController();
                degree = controller.DegreeProgram_byID(int.Parse(DegreeList.SelectedValue));

                //Split string before populating form
                programLength = degree.DegreeLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = degree.DegreeID.ToString();
                ProgramName.Text               = degree.DegreeName;
                CategoryList.SelectedValue     = degree.CategoryID.ToString();
                CredentialType.Text            = "Degree";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = degree.DegreeLink;
                Activated.Checked              = degree.Activated;
                WorkOutdoors.Checked           = degree.WorkOutdoors;
                ShiftWork.Checked              = degree.ShiftWork;
                Travel.Checked                 = degree.WorkTravel;

                pathwaysheading_toggle.Visible = true;
                EntReqListView.Visible         = false;
                DegreePathListView.Visible     = true;
                DiplomaEntReqList.Visible      = false;
                DiplomaPathListView.Visible    = false;
                entrance_req.Visible           = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = degree.DegreeLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = degree.DegreeName;

                DegreePathListView.DataSource = DipRelDB_ODS;
                DegreePathListView.DataBind();
            }

            else
            {
                DegreePathListView.Visible     = false;
                DiplomaEntReqList.Visible      = false;
                DiplomaPathListView.Visible    = false;
                pathwaysheading_toggle.Visible = false;
                EntReqListView.Visible         = false;
                entrance_req.Visible           = false;
            }
        });
    }
Ejemplo n.º 18
0
        protected void PlaceOrder_Click(object sender, EventArgs e)
        {
            List <SaleDetailsList> listsaledetails = new List <SaleDetailsList>();
            List <ListSale>        listsales       = new List <ListSale>();
            string username = User.Identity.Name;
            int    employeeid;

            if (SaleList.Items.Count == 0)
            {
                MessageUserControl.ShowInfo("Warning", "Please add at least one product in order to place order.");
            }
            else
            {
                if (PaymentTypeDDL.SelectedIndex == 0)
                {
                    MessageUserControl.ShowInfo("Warning", "Please select a payment method to place order.");
                }
                else
                {
                    MessageUserControl.TryRun(() =>
                    {
                        ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                        EmployeeInfo info             = secmgr.User_GetEmployee(username);
                        employeeid = info.EmployeeID;

                        foreach (ListViewItem item in SaleList.Items)
                        {
                            Label quantityLabel     = item.FindControl("QuantityLabel") as Label;
                            Label priceLabel        = item.FindControl("PriceLabel") as Label;
                            HiddenField itemIDLabel = item.FindControl("StockItemIDLabel") as HiddenField;
                            Label descriptionLabel  = item.FindControl("DescriptionLabel") as Label;

                            SaleDetailsList newSaleDetailsList = new SaleDetailsList();
                            newSaleDetailsList.Description     = descriptionLabel.Text;
                            newSaleDetailsList.Price           = decimal.Parse(priceLabel.Text.Replace(@"$", string.Empty));
                            newSaleDetailsList.Quantity        = int.Parse(quantityLabel.Text);
                            newSaleDetailsList.StockItemID     = int.Parse(itemIDLabel.Value);
                            listsaledetails.Add(newSaleDetailsList);
                        }

                        Label SubtotalLabel    = (Label)UpdatePanel3.FindControl("totalLabel2") as Label;
                        Label taxLabel         = (Label)UpdatePanel3.FindControl("TaxLabel") as Label;
                        CouponController cpmgr = new CouponController();
                        Coupon coupon          = cpmgr.Coupons_Get(CouponTextBox.Text);

                        ListSale newSaleList    = new ListSale();
                        newSaleList.PaymentType = PaymentTypeDDL.SelectedItem.ToString();
                        newSaleList.CouponID    = coupon == null ? null : coupon.CouponID;
                        newSaleList.SubTotal    = decimal.Parse(SubtotalLabel.Text.Replace(@"$", string.Empty));
                        newSaleList.TaxAmount   = decimal.Parse(taxLabel.Text.Replace(@"$", string.Empty));
                        listsales.Add(newSaleList);

                        SaleDetailController sysmgr = new SaleDetailController();
                        sysmgr.Add_AddToSale(employeeid, listsales, listsaledetails);

                        foreach (ListViewItem item in SaleList.Items)
                        {
                            HiddenField itemidLabel = item.FindControl("ItemIDLabel") as HiddenField;
                            int itemid = int.Parse(itemidLabel.Value);
                            ShoppingCartItemController spcitemmgr = new ShoppingCartItemController();
                            spcitemmgr.DeleteShoppingItems(employeeid, itemid);
                        }

                        ShoppingCartController spcmgr = new ShoppingCartController();
                        spcmgr.DeleteShoppingCart(employeeid);

                        //refresh the table
                        ShoppingCartItemController systemmgr = new ShoppingCartItemController();
                        List <UserShoppingCartItem> infos    = systemmgr.List_ItemsForShoppingCart(employeeid);
                        ShoppingCartList.DataSource          = infos;
                        ShoppingCartList.DataBind();

                        subtotalLabel.Text           = "$" + "0";
                        TaxLabel.Text                = "$" + "0";
                        CouponTextBox.Text           = "";
                        DiscountLabel.Text           = "$" + "0";
                        totalLabel2.Text             = "$" + "0";
                        PaymentTypeDDL.SelectedIndex = 0;
                    }, "Success", "Order has been placed");
                }
            }
        }
Ejemplo n.º 19
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun(() =>
     {
     }, "Saving", "Order Saved");
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Executed when the user clicks on "View Order"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ReceivingVendorOrderGridView_SelectedIndexChanged(object sender, EventArgs e)
 {
     ReceivingItemsDiv.Visible = true;
     MessageUserControl.TryRun((ProcessRequest)ViewOrder);
 }
Ejemplo n.º 21
0
 protected void CheckForExceptions(object sender, ObjectDataSourceStatusEventArgs e)
 {
     // Works for OnInsert, OnUpdate, and onDelete events of the ODS control.
     MessageUserControl.HandleDataBoundException(e);
 }
Ejemplo n.º 22
0
    /// <summary>
    /// Executed when the user clicks on the Receive button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ReceiveButton_Click(object sender, EventArgs e)
    {
        currentItemsList.Clear(); // starts the list from scratch

        foreach (GridViewRow row in ReceivingItemsGridView.Rows)
        {
            // Gets all values from the GridView
            int     stockItemID = int.Parse(row.Cells[0].Text);
            string  stockItemDescription = row.Cells[1].Text;
            int     quantityOrdered = int.Parse(row.Cells[2].Text);
            int     quantityOutstanding = int.Parse(row.Cells[3].Text);
            TextBox receiveInput, returnInput, reasonInput;
            receiveInput = row.FindControl("ReceiveTextBox") as TextBox;
            returnInput  = row.FindControl("ReturnTextBox") as TextBox;
            reasonInput  = row.FindControl("ReasonTextBox") as TextBox;
            string receiveText = receiveInput.Text.Trim();
            string returnText  = returnInput.Text.Trim();
            string reasonText  = reasonInput.Text.Trim();

            // Replaces empty texts in quantities with zeros
            if (String.IsNullOrEmpty(receiveText))
            {
                receiveText       = "0";
                receiveInput.Text = receiveText;
            }
            if (String.IsNullOrEmpty(returnText))
            {
                returnText       = "0";
                returnInput.Text = returnText;
            }

            // Gets booleans to validate numbers
            int  receiveNumber;
            bool receiveIsNumber = int.TryParse(receiveText, out receiveNumber);
            int  returnNumber;
            bool returnIsNumber = int.TryParse(returnText, out returnNumber);

            // Validation
            if (!receiveIsNumber || !returnIsNumber || receiveNumber < 0 || returnNumber < 0)
            {
                // Validates integers
                MessageUserControl.ShowInfo("Only positive integers are allowed in the Receive and Return fields.");
                return;
            }
            else if (receiveNumber > quantityOutstanding)
            {
                // Quantity received must not be greater than the quantity outstanding
                MessageUserControl.ShowInfo("Quantity received must not be greater than the quantity outstanding.");
                return;
            }
            else if (returnNumber > quantityOutstanding)
            {
                // Quantity returned must not be greater than the quantity outstanding
                MessageUserControl.ShowInfo("Quantity returned must not be greater than the quantity outstanding.");
                return;
            }
            else if ((receiveNumber + returnNumber) > quantityOutstanding)
            {
                // Receive and return fields summed cannot exceed the outstanding field
                MessageUserControl.ShowInfo("The number of items to receive and return cannot exceed the number of outstanding items.");
                return;
            }
            else if (int.Parse(returnText) > 0 && reasonText == "")
            {
                // Returned items must have reasons specified
                MessageUserControl.ShowInfo("You must specify a reason for all items to be returned.");
                return;
            }
            else if (!String.IsNullOrEmpty(reasonText) && int.Parse(returnText) < 1)
            {
                // Specified reasons must have returned quantities entered
                MessageUserControl.ShowInfo("You must specify the quantity of all items to be returned.");
                return;
            }
            else
            {
                // Adds row to the temporary list
                ReceivingItems receivingItems = new ReceivingItems();
                receivingItems.StockItemID          = stockItemID;
                receivingItems.StockItemDescription = Server.HtmlDecode(stockItemDescription); // Server.HtmlDecode reverses HTML encode changes made (e.g. & converted to amp;)
                receivingItems.QuantityOrdered      = quantityOrdered;
                receivingItems.QuantityOutstanding  = quantityOutstanding;
                receivingItems.QuantityReceived     = int.Parse(receiveText);
                receivingItems.QuantityReturned     = int.Parse(returnText);
                receivingItems.ReturnReason         = Server.HtmlDecode(reasonText); // Server.HtmlDecode reverses HTML encode changes made (e.g. & converted to amp;)

                currentItemsList.Add(receivingItems);
            }
        }

        // Checks if a field was changed to proceed with adding a new receive order
        foreach (var item in currentItemsList)
        {
            if (item.QuantityReceived > 0 || item.QuantityReturned > 0)
            {
                currentOrderId = (int)ReceivingItemsGridView.DataKeys[0].Value; // gets the order ID from a DataKey
                MessageUserControl.TryRun((ProcessRequest)SubmitReceiveOrder, "Receive Order", "Sucessfully updated the Purchase Order information.");
                return;
            }
        }

        // Displays a message if the user does not make changes in any field
        MessageUserControl.ShowInfo("No changes were made since no fields were edited.");
        ClearAndRefreshPage();
    }
Ejemplo n.º 23
0
    /*
     * CREATED:     E. Lautner		APR 1 2018
     *
     * Page_Load()
     * Run on page load and is used to display the selected accounts details
     *
     * PARAMETERS:
     * object sender - references the object that raised the Page_Load event
     * EventArgs e - optional class that may be passed that inherits from EventArgs (usually empty)
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * MessageUserControl.ShowErrorMessage()
     * UserManager.FindByName()
     * UserManager.GetRoles()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (AuthorizationLevelRolesRadioList.SelectedValue == AuthorizationLevelRoles.User)
            {
                CareSiteDDL.Visible   = true;
                CareSiteLabel.Visible = true;
            }
            else
            {
                CareSiteDDL.Visible   = false;
                CareSiteLabel.Visible = false;
            }
        }
        else
        {
            try
            {
                sentUserName = Request.QueryString["id"];
                if (sentUserName == "administratoraccount") //can't modify webmaster
                {
                    Response.Redirect("~/Management/accounts");
                }
                else
                {
                    if (sentUserName == null)
                    {
                        Response.Redirect("~/Management/accounts");
                    }
                    else
                    {
                        UsernameLabel.Text = sentUserName;

                        UserManager userManager  = new UserManager();
                        var         selectedUser = userManager.FindByName(sentUserName);

                        if (selectedUser == null)
                        {
                            Response.Redirect("~/Management/accounts");
                        }
                        if (selectedUser.activeyn == true)
                        {
                            PasswordBtn.Visible             = true;
                            DeactivateAccountButton.Visible = true;
                            UpdateAccountButton.Visible     = true;
                            FirstNameTB.Enabled             = true;
                            LastNameTB.Enabled = true;
                            EmailTB.Enabled    = true;
                            AuthorizationLevelRolesRadioList.Enabled = true;
                            CareSiteDDL.Enabled = true;

                            if (selectedUser.Id == Context.User.Identity.GetUserId())
                            {
                                DeactivateAccountButton.Visible          = false;
                                AuthorizationLevelRolesRadioList.Enabled = false;
                            }
                        }
                        else
                        {
                            PasswordBtn.Visible             = false;
                            DeactivateAccountButton.Visible = false;
                            UpdateAccountButton.Visible     = false;
                            FirstNameTB.Enabled             = false;
                            LastNameTB.Enabled = false;
                            EmailTB.Enabled    = false;
                            AuthorizationLevelRolesRadioList.Enabled = false;
                            CareSiteDDL.Enabled = false;
                        }

                        var userRoles = userManager.GetRoles(selectedUser.Id);

                        string userRole = string.Join("", userRoles.ToArray());

                        FirstNameTB.Text = selectedUser.firstname;
                        LastNameTB.Text  = selectedUser.lastname;
                        EmailTB.Text     = selectedUser.Email;

                        CareSiteDDL.SelectedValue = selectedUser.caresiteid.ToString();
                        if (selectedUser.caresiteid == null)
                        {
                            CareSiteDDL.SelectedValue = "0";
                        }

                        AuthorizationLevelRolesRadioList.SelectedValue = userRole;

                        if (userRole == AuthorizationLevelRoles.Administrator || userRole == AuthorizationLevelRoles.Super_User)
                        {
                            CareSiteDDL.Visible   = false;
                            CareSiteLabel.Visible = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageUserControl.ShowErrorMessage("Retrieving account information from the database failed. Please try again. If error persists, please contact your administrator.", ex);
            }
        }
    }
    protected void receiveBtn_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            MessageUserControl.TryRun(() =>
            {
                ReceivingOrderController sysmgr      = new ReceivingOrderController();
                List <ReceiveNewOrders> recNewOrders = new List <ReceiveNewOrders>();
                int poId       = 0;
                int poDetailId = 0;
                int qty        = 0;
                int poNumber   = int.Parse(PONumber.Text);

                foreach (GridViewRow row in OrderDetailGrid.Rows)
                {
                    poId                   = int.Parse(((Label)row.FindControl("PurchaseOrderId")).Text);
                    poDetailId             = int.Parse(((Label)row.FindControl("PurchaseOrderDetailId")).Text);
                    string qtyReceived     = ((TextBox)row.FindControl("receiving")).Text;
                    string qtyReturning    = ((TextBox)row.FindControl("returning")).Text;
                    string reason          = ((TextBox)row.FindControl("reason")).Text;
                    string outstanding     = ((Label)row.FindControl("qtyOutstanding")).Text;
                    string partId          = ((Label)row.FindControl("partId")).Text;
                    string partDescription = ((Label)row.FindControl("description")).Text;

                    if (string.IsNullOrEmpty(qtyReturning) && !string.IsNullOrEmpty(reason))
                    {
                        MessageUserControl.ShowInfo("Entry Error", "A reason can not be provided if no return is being made.");
                    }
                    else
                    {
                        ReceiveNewOrders recOrderDetail      = new ReceiveNewOrders();
                        recOrderDetail.PurchaseOrderDetailId = poDetailId;
                        if (!string.IsNullOrEmpty(qtyReceived))
                        {
                            recOrderDetail.QtyReceived = int.Parse(qtyReceived);
                        }
                        if (!string.IsNullOrEmpty(qtyReturning))
                        {
                            recOrderDetail.QtyReturned = int.Parse(qtyReturning);
                        }
                        recOrderDetail.Notes = reason;
                        if (!string.IsNullOrEmpty(partId))
                        {
                            recOrderDetail.PartId = int.Parse(partId);
                        }
                        recOrderDetail.PartDescription = partDescription;
                        if (!string.IsNullOrEmpty(outstanding))
                        {
                            recOrderDetail.Outstanding = int.Parse(outstanding);
                        }
                        recNewOrders.Add(recOrderDetail);
                    }
                }
                sysmgr.Add_ReceivedOrders(poId, poNumber, recNewOrders);

                refreshForm();

                disableButtons();
            }, "Order", "New items have been added successfully");
        }
    }
Ejemplo n.º 25
0
 protected void InsertWaiter_Click(object sender, EventArgs e)
 {
     MessageUserControl.TryRun((ProcessRequest)InsertWaiterInfo);
 }
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            string           username    = "******"; //until security is implemented
            List <Exception> brokenRules = new List <Exception>();

            //form event validation: presence
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                brokenRules.Add(new BusinessRuleException <string>("Enter a playlist name", "PlayList name", "missing"));
                //MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Track Removal", "You must have a playlist visible to choose removals. Select from the displayed playlist.");
                }
                else
                {
                    //collect the tracks indicated on the playlist for removal
                    List <int> trackids       = new List <int>();
                    int        rowsSelected   = 0;
                    CheckBox   trackSelection = null;
                    //traverse the gridview control PlayList
                    //you could do this same code using a foreach()
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        //point to the checkbox control on the gridview row
                        trackSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        //test the setting of the checkbox
                        if (trackSelection.Checked)
                        {
                            rowsSelected++;
                            trackids.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                        }
                    }

                    //was a song selected
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Missing Data", "You must select at least one song to remove.");
                    }
                    else
                    {
                        //data collected, send for processing
                        MessageUserControl.TryRun(() =>
                        {
                            if (brokenRules.Count > 0)
                            {
                                throw new BusinessRuleCollectionException("Delete Track", brokenRules);
                            }
                            else
                            {
                                PlaylistTracksController sysmgr = new PlaylistTracksController();
                                sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);
                                RefreshPlayList(sysmgr, username);
                            }
                        }, "Track removal", "Selected track(s) have been removed from the playlist.");
                    }
                }
            }
        }
Ejemplo n.º 27
0
    /// <summary>
    /// Handles the actions executed by command buttons found in the Answers list view
    /// </summary>
    /// <param name="sender">Contains a reference to the control/object that raised the event.</param>
    /// <param name="e">Provides data for the ItemCommand event, which occurs when a button in a ListView is clicked.</param>
    protected void UpdateAnswersListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //If the Edit button is clicked, do the following actions:
        if (e.CommandName.Equals("Edit"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Edit Mode Active", "The answer text in the selected row can now be edited.");

            //disable drop-down list and fetch button to prevent editing of answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = false;
            FetchAnswersButton.Enabled = false;
        }
        //If the Change button is clicked, do the following actions:
        else if (e.CommandName.Equals("Change"))
        {
            //capture the answer Id of the selected row
            int answerId = int.Parse(e.CommandArgument.ToString());
            //capture the row index of the selected row
            int i = e.Item.DisplayIndex;

            //find the answer textbox in the selected row
            TextBox answerTextBox = UpdateAnswersListView.Items[i].FindControl("descriptionTextBox") as TextBox;

            //capture the answer text from the textbox
            string answerText = answerTextBox.Text;

            //handle null values and white-space-only values
            if (string.IsNullOrEmpty(answerText) || string.IsNullOrWhiteSpace(answerText))
            {
                //show error message
                MessageUserControl.Visible = true;
                MessageUserControl.ShowInfoError("Processing Error", "Answer is required.");

                //highlight the answer textbox in the row that caused the error
                answerTextBox.Focus();
            }
            //if user-entered value is not null or just a white space, do the the following actions:
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    //check if user entered invalid values
                    Utility utility = new Utility();
                    utility.checkValidString(answerText);

                    //update the answer text of the selected row
                    AnswerController sysmgr = new AnswerController();
                    sysmgr.Answer_Update(answerText, answerId);
                    UpdateAnswersListView.DataBind();
                    UpdateAnswersListView.EditIndex = -1;
                }, "Success", "Answer has been updated.");
            }

            //show success/error message
            MessageUserControl.Visible = true;

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
        //If the Cancel button is clicked, do the following actions:
        else if (e.CommandName.Equals("Cancel"))
        {
            //show informational message
            MessageUserControl.Visible = true;
            MessageUserControl.ShowInfo("Update canceled", "No changes to the selected answer were saved.");

            //show datapager
            DataPager pager = UpdateAnswersListView.FindControl("ActiveDataPager") as DataPager;
            pager.Visible = true;

            //enable drop-down list and fetch button to allow editing of other answers to other questions
            QuestionsWithAnswersDropDownList.Enabled = true;
            FetchAnswersButton.Enabled = true;
        }
    }
Ejemplo n.º 28
0
        protected void CartSalesGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("Refresh"))
            {
                PanelPaymentButtons.Visible = true;
                int productid = int.Parse(e.CommandArgument.ToString());
                int qty       = 0;
                for (int rowindex = 0; rowindex < CartSalesGridView.Rows.Count; rowindex++)
                {
                    if ((CartSalesGridView.Rows[rowindex].FindControl("ProductID") as Label).Text == e.CommandArgument.ToString())
                    {
                        qty = int.Parse((CartSalesGridView.Rows[rowindex].FindControl("Quantity") as TextBox).Text);
                    }
                }
                if (qty <= 0)
                {
                    MessageUserControl.ShowInfo("Quantity Cannot be negative number or zero, Please add quantity or remove the item from your Cart.");
                }
                else
                {
                    var username = User.Identity.Name;
                    SecurityController securitymgr = new SecurityController();
                    int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
                    EmployeeController sysmgrs = new EmployeeController();
                    Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

                    int employeeID = info.EmployeeID;

                    MessageUserControl.TryRun(() =>
                    {
                        ShoppingCartController sysmgr = new ShoppingCartController();

                        //Call for adjusting quantity
                        sysmgr.Quantity_Refresh(employeeID, productid, qty);

                        List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                        CartSalesGridView.DataSource = datainfo;
                        CartSalesGridView.DataBind();
                    }, "Refreshing", "Item Quantity Updated");
                    var controller = new ShoppingCartController();
                    var countTotal = controller.ShoppingCart_OrderList();
                    SubtotalText.Text = countTotal.Sum(x => x.Quantity * x.Price).ToString();
                    TaxText.Text      = countTotal.Sum(t => t.Quantity * t.Price * decimal.Parse(0.05.ToString())).ToString();
                    TotalText.Text    = countTotal.Sum(tos => tos.Quantity * tos.Price * decimal.Parse(0.05.ToString()) + (tos.Quantity * tos.Price)).ToString();
                }
            }
            else
            {
                PanelPaymentButtons.Visible = true;
                int productid = int.Parse(e.CommandArgument.ToString());


                var username = User.Identity.Name;
                SecurityController securitymgr = new SecurityController();
                int?employeeid             = securitymgr.GetCurrentUserEmployeeId(username);
                EmployeeController sysmgrs = new EmployeeController();
                Employee           info    = sysmgrs.Employee_Get(employeeid.Value);

                int employeeID = info.EmployeeID;

                MessageUserControl.TryRun(() =>
                {
                    ShoppingCartController sysmgr = new ShoppingCartController();

                    sysmgr.Delete_ProductItem(employeeID, productid);

                    List <ShoppingCart> datainfo = sysmgr.ShoppingCart_OrderList();
                    CartSalesGridView.DataSource = datainfo;
                    CartSalesGridView.DataBind();
                }, "Deleting Product", "Item Has been Removed from the Cart");
                var controller = new ShoppingCartController();
                var countTotal = controller.ShoppingCart_OrderList();
                SubtotalText.Text = countTotal.Sum(x => x.Quantity * x.Price).ToString("C");
                TaxText.Text      = countTotal.Sum(t => t.Quantity * t.Price * decimal.Parse(0.05.ToString())).ToString("C");
                TotalText.Text    = countTotal.Sum(tos => tos.Quantity * tos.Price * decimal.Parse(0.05.ToString()) + (tos.Quantity * tos.Price)).ToString("C");
            }
        }
Ejemplo n.º 29
0
 protected void CheckForException(object sender, ObjectDataSourceStatusEventArgs e)
 {
     MessageUserControl.HandleDataBoundException(e);
 }
Ejemplo n.º 30
0
        protected void EquipmentAdd(object sender, CommandEventArgs e)
        {
            string username = User.Identity.Name;
            int    employeeid;
            int    equipmentid = int.Parse(e.CommandArgument.ToString());
            int    customerid  = int.Parse(CurrentCustomerID.Text);

            //ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
            //EmployeeInfo info = secmgr.User_GetEmployee(username);
            employeeid = 1;//info.EmployeeID;
            List <RentalDetailRecord> details   = new List <RentalDetailRecord>();
            List <RentalEquipment>    einfoList = new List <RentalEquipment>();

            ShowCouponForm();

            if (employeeid == 0)
            {
                MessageUserControl.ShowInfo("Warning", "Please login as an Employee!");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    RentalRecord Record       = null;
                    RentalDetailRecord Detail = null;


                    if (CurrentRentalDetailListView.Items.Count == 0)
                    {
                        Record = new RentalRecord();
                        Detail = new RentalDetailRecord();

                        Detail.RentalEquipmentID = equipmentid;

                        RentalEquipmentController resysmgr = new RentalEquipmentController();
                        RentalEquipment reinfo             = resysmgr.Equipment_Find_byID(equipmentid);

                        Detail.DailyRate    = reinfo.DailyRate;
                        Detail.Days         = 1;
                        Detail.ConditionOut = reinfo.Condition;
                        Detail.Paid         = false;


                        Record.RentalDate = DateTime.Now;
                        if (Detail == null)
                        {
                            MessageUserControl.ShowInfo("Warning", "Create new Rental failed!");
                        }
                        else
                        {
                            details.Add(Detail);
                        }

                        Record.Details           = details;
                        RentalController rsysmgr = new RentalController();
                        rsysmgr.Create_newRentalRecord(customerid, employeeid, Record);

                        einfoList.Add(reinfo);

                        CurrentRentalDetailListView.DataSource = einfoList;
                        CurrentRentalDetailListView.DataBind();
                    }
                    else
                    {
                        Detail = new RentalDetailRecord();
                        Detail.RentalEquipmentID = equipmentid;



                        RentalDetailController rdsysmgr = new RentalDetailController();
                        var dinfo = rdsysmgr.List_RentalDetail_forRental(customerid, employeeid, Record.RentalDate);

                        foreach (var item in dinfo)
                        {
                            RentalEquipmentController resysmgr = new RentalEquipmentController();
                            RentalEquipment reinfo             = resysmgr.Equipment_Find_byID(item.RentalEquipmentID);
                            Detail.DailyRate    = reinfo.DailyRate;
                            Detail.Days         = 1;
                            Detail.ConditionOut = reinfo.Condition;
                            Detail.Paid         = false;
                            einfoList.Add(reinfo);
                        }

                        CurrentRentalDetailListView.DataSource = einfoList;
                        CurrentRentalDetailListView.DataBind();
                    }
                }, "Found", "Customer(s) has been found");
            }
        }