Beispiel #1
0
        protected void btnSubmitOrder_Click(object sender, EventArgs e)
        {
            // instantiate object for access to methods //
            clsCustomers c = new clsCustomers();

            try
            {
                // First enter into orders table //
                // get customerID
                int custID = Convert.ToInt32(Session["customerID"]);

                // set order status to pending for order //
                string status = "pending";

                // submit order to Orders table //
                c.submitOrder(custID, status);

                // 2. get order ID and submit order details
                // variable to store current order ID of order
                int orderNumber;

                // method to access customer's newly placed order //
                orderNumber = c.getOrderedID(custID);

                // convert product ID to int //
                //int itemID = Convert.ToInt32(lblPoduct.Text);

                // variable to store the product's ID //
                int proID = Convert.ToInt32(Request.QueryString["productType"]);

                // get product name by its ID //
                string proName = c.getDdlProductName(proID);

                // get customer quantity //
                int custQty = Convert.ToInt32(lblQuantity.Text);

                // calculate grand total //
                decimal gTotal;
                int     ttlAmtItems = Convert.ToInt32(lblQuantity.Text);
                decimal costPerItem = Convert.ToDecimal(lblCostPerItem.Text);
                gTotal = ttlAmtItems * costPerItem;

                // get/set customer text //
                string description = lblTextDesc.Text;

                string fileUploadNm = " ";


                c.submitOrderDetails(orderNumber, custID, proID, proName, custQty, costPerItem, gTotal, description, fileUploadNm);

                // inform customer that order was submitted and return confirmation and confirmation number (order number) //
                lblOrderSuccess.Text = "Order successfully submitted, confirmation number: " + orderNumber.ToString();

                //
                btnSubmitOrder.Visible = false;
                lnkGoBack.Visible      = false;
                lnkPlaceOrder.Visible  = true;

                // 3.
            }
            catch (Exception ex)
            {
                string error = "Error occurred please try again later.. " + ex.ToString();
                lblError.Text = error;
                //error + ex.ToString();
            }
        } /* btnSubmitOrder_Click() */
        } /* end Page_Load() */

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                try
                {
                    // get access to methods from class //
                    clsCustomers c = new clsCustomers();

                    // get customer ID and convert to INT //
                    int custID = Convert.ToInt32(Session["customerID"]);

                    // get the file name in to filename variable and get file extension //
                    string filename  = Path.GetFileName(FileUpload1.FileName);
                    string extension = Path.GetExtension(filename);

                    // get current date/time/second //
                    string getCurrentDate = DateTime.Now.ToString("_yyy-MM-dd-h-mm-tt");

                    // set order status to pending for order //
                    string status = "pending";

                    // submit order to Orders table //
                    c.submitOrder(custID, status);

                    int orderNumber;

                    // method to access customer's newly placed order //
                    orderNumber = c.getOrderedID(custID);

                    // variable to store the product's ID //
                    int proID = Convert.ToInt32(Request.QueryString["printType"]);

                    // get product name by its ID //
                    string proName = c.getDdlProductName(proID);

                    // calculate the grand total //
                    int     ttlAmtItems = Convert.ToInt32(Request.QueryString["qty"]);
                    decimal gTotal;
                    decimal costPerItem = Convert.ToDecimal(lblPricePerPage.Text);
                    gTotal = ttlAmtItems * costPerItem;

                    // get customer quantity //
                    int custQty = ttlAmtItems;

                    // get the customer input text //
                    string description = lblDesc.Text;

                    string fullFileNameAndDate = filename + getCurrentDate + extension;

                    // save the selected file to the specified folder //
                    FileUpload1.SaveAs(Server.MapPath("PrintJobUploads/") + fullFileNameAndDate);


                    // insert order to orderDetails table //
                    c.submitOrderDetails(orderNumber, custID, proID, proName, ttlAmtItems, costPerItem, gTotal, description, fullFileNameAndDate);


                    // get file name for input to database //
                    lblUploadSuccess.Text = "File has been successfully uploaded to: " + filename + getCurrentDate + extension;


                    // inform customer that order was submitted and return confirmation and confirmation number (order number) //
                    lblUploadSuccess.Text = "Order successfully submitted, confirmation number: " + orderNumber.ToString();

                    btnSubmit.Visible     = false;
                    lnkGoBack.Visible     = false;
                    lnkPlaceOrder.Visible = true;
                    FileUpload1.Visible   = false;
                } /* end try{} */

                catch (Exception ex)
                {
                    lblUploadSuccess.Text = "Error occurred: " + ex.ToString();
                } /* end catch{} */
            }     /* end if statement */
        }