Esempio n. 1
0
        private void loadInvoice()
        {
            //display the invoice
            int rowCount = 0;

            //get the details from the db
            try
            {
                //get booking deatils
                SP_GetCustomerBooking BookingDetails = handler.getCustomerPastBookingDetails(SaleID);
                SALE invoice = handler.getSale(SaleID);
                List <SP_getInvoiceDL> invoicDetailLines = handler.getInvoiceDL(SaleID);

                if (invoicDetailLines.Count != 0)
                {
                    #region Company Details / Invoice Date
                    //diaplay a heading
                    TableRow newRow = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    TableCell newCell = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Font.Bold = true;
                    newCell.Text      = "<a class='navbar-brand js-scroll-trigger' href='#' onClick='window.print()'>Cheveux </a>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #region EmptyCells
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion
                    newCell           = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Text      = "Invoice";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    #region Break Line
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell      = new TableCell();
                    newCell.Text = "<br/>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "<br/>";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    //from address
                    BUSINESS bUSINESS = handler.getBusinessTable();
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell      = new TableCell();
                    newCell.Text = bUSINESS.AddressLine1 + "<br/>" + bUSINESS.AddressLine2;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    #region EmptyCells
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion

                    #region  date
                    newCell = new TableCell();

                    newCell.Text = invoice.Date.ToString("HH:mm dd MMM yyyy");
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Billed To
                    //Billed to
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);
                    newCell           = new TableCell();
                    newCell.Font.Bold = true;
                    newCell.Text      = "Billed To:";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell      = new TableCell();
                    newCell.Text = handler.GetUserDetails(invoice.CustID).FirstName.ToString() + " " +
                                   handler.GetUserDetails(invoice.CustID).LastName.ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Stylist
                    if (BookingDetails != null)
                    {
                        newRow        = new TableRow();
                        newRow.Height = 50;
                        tblInvoice.Rows.Add(newRow);
                        newCell           = new TableCell();
                        newCell.Font.Bold = true;
                        newCell.Text      = "Services Renderd By:";
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);
                        newCell      = new TableCell();
                        newCell.Text = BookingDetails.stylistFirstName;
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //increment row count
                        rowCount++;
                    }
                    #endregion

                    //calculate total price
                    double total = 0.0;

                    #region Items
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    #region header
                    //fill in the item
                    newCell           = new TableCell();
                    newCell.Text      = "Item";
                    newCell.Font.Bold = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell           = new TableCell();
                    newCell.Text      = "Qty";
                    newCell.Font.Bold = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell                 = new TableCell();
                    newCell.Text            = "Unit Price";
                    newCell.Font.Bold       = true;
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in the Qty, unit price & TotalPrice
                    newCell                 = new TableCell();
                    newCell.Text            = "Total";
                    newCell.Font.Bold       = true;
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    foreach (SP_getInvoiceDL item in invoicDetailLines)
                    {
                        newRow        = new TableRow();
                        newRow.Height = 50;
                        tblInvoice.Rows.Add(newRow);

                        //fill in the item
                        newCell      = new TableCell();
                        newCell.Text = item.itemName.ToString();
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        newCell      = new TableCell();
                        newCell.Text = item.Qty.ToString();
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        newCell = new TableCell();
                        newCell.HorizontalAlign = HorizontalAlign.Right;
                        newCell.Text            = "R" + string.Format("{0:#.00}", item.price);
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //fill in the Qty, unit price & TotalPrice
                        newCell = new TableCell();
                        newCell.HorizontalAlign = HorizontalAlign.Right;
                        newCell.Text            = "R" + string.Format("{0:#.00}", item.Qty * item.price);
                        tblInvoice.Rows[rowCount].Cells.Add(newCell);

                        //increment final price
                        total += item.Qty * item.price;

                        //increment row count
                        rowCount++;
                    }
                    #endregion

                    #region Excluding Vat Info
                    // get vat info
                    Tuple <double, double> vatInfo = function.getVat(total);

                    //display total including and Excluding VAT
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> Excluding VAT: &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    //fill in total ExcludingVAT
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = " <br/> R " + string.Format("{0:#.00}", vatInfo.Item1, 2);
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region VAT RAte
                    //get the vat rate
                    double VATRate = -1;
                    try
                    {
                        VATRate = handler.GetVATRate().VATRate;
                    }
                    catch (Exception Err)
                    {
                        function.logAnError(Err.ToString());
                    }

                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in total VAT due
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "VAT @" + VATRate + "% &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "R " + string.Format("{0:#.00}", vatInfo.Item2, 2).ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //increment row count
                    rowCount++;
                    #endregion

                    #region Total
                    //display the total due
                    newRow        = new TableRow();
                    newRow.Height = 50;
                    tblInvoice.Rows.Add(newRow);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    newCell      = new TableCell();
                    newCell.Text = "";
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);

                    //fill in total
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> Total Due: &nbsp; ";
                    newCell.Font.Bold       = true;
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    newCell = new TableCell();
                    newCell.HorizontalAlign = HorizontalAlign.Right;
                    newCell.Text            = "<br/> R " + string.Format("{0:#.00}", total).ToString();
                    tblInvoice.Rows[rowCount].Cells.Add(newCell);
                    #endregion
                }
                else
                {
                    function.logAnError("Error Loading Print Invoice ");
                    Response.Redirect("Error.aspx?Error='An Error Occured Communicating With The Data Base, Try Again Later'");
                }
            }
            catch (Exception Err)
            {
                function.logAnError("Error Loading Print Invoice | Error: " + Err.ToString());
                Response.Redirect("Error.aspx?Error='An Error Occured Communicating With The Data Base, Try Again Later'");
            }
        }
Esempio n. 2
0
        private void loadHomePage()
        {
            #region Redirect
            //rediret to product page or stylist profile with product id
            //check if a redirect has been requested
            String goTo = Request.QueryString["Goto"];
            if (goTo != null)
            {
                features = null;
                try
                {
                    //get the home page featurs
                    features = handler.GetHomePageFeatures();
                }
                catch (Exception err)
                {
                    function.logAnError("unable to load featurd items from the DB on default.aspx for redirect: " +
                                        err);
                }

                if (goTo == "Prod1")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Products.aspx");
                    }
                    else
                    {
                        Response.Redirect("/Cheveux/Products.aspx?ProductID=" + features[0].ItemID.ToString());
                    }
                }
                else if (goTo == "Prod2")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Products.aspx");
                    }
                    else
                    {
                        Response.Redirect("/Cheveux/Products.aspx?ProductID=" + features[1].ItemID.ToString());
                    }
                }
                else if (goTo == "Prod3")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Products.aspx");
                    }
                    else
                    {
                        Response.Redirect("/Cheveux/Products.aspx?ProductID=" + features[2].ItemID.ToString());
                    }
                }
                else if (goTo == "Sty1")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Stylists.aspx");
                    }
                    else
                    {
                        Response.Redirect("Profile.aspx?Action=View&empID=" + features[7].ItemID.ToString());
                    }
                }
                else if (goTo == "Sty2")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Stylists.aspx");
                    }
                    else
                    {
                        Response.Redirect("Profile.aspx?Action=View&empID=" + features[8].ItemID.ToString());
                    }
                }
                else if (goTo == "Sty3")
                {
                    if (features == null)
                    {
                        Response.Redirect("/Cheveux/Stylists.aspx");
                    }
                    else
                    {
                        Response.Redirect("Profile.aspx?Action=View&empID=" + features[9].ItemID.ToString());
                    }
                }
                else if (goTo == "Phone")
                {
                    if (features == null)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Error.aspx','_newtab');", true);
                        Response.Redirect("Error.aspx");
                    }
                    else
                    {
                        Response.Redirect("tel:" + features[10].contactNo.ToString());
                    }
                }
                else if (goTo == "Email")
                {
                    if (features == null)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('Error.aspx','_newtab');", true);
                        Response.Redirect("Error.aspx");
                    }
                    else
                    {
                        Response.Redirect("mailto:" + features[11].email.ToString());
                    }
                }
            }

            #endregion

            #region access control
            HttpCookie UserID = Request.Cookies["CheveuxUserID"];
            //send the user to the correct page based on their usertype
            if (UserID != null)
            {
                string userType = UserID["UT"].ToString();
                if ("R" == userType)
                {
                    //Receptionist
                    Response.Redirect("/Receptionist/Receptionist.aspx");
                }
                else if (userType == "M")
                {
                    //Manager
                    Response.Redirect("/Manager/Dashboard.aspx");
                }
                else if (userType == "S")
                {
                    //stylist
                    Response.Redirect("/Stylist/Stylist.aspx");
                }
                else if (userType == "C")
                {
                    //customer
                    //allowed access to this page
                    //Response.Redirect("Default.aspx");
                }
                else
                {
                    function.logAnError("Unknown user type found during Loading of default.aspx: " +
                                        UserID["UT"].ToString());
                }
            }
            #endregion

            #region Home Page Info
            //load home page info
            #region Welcom Back
            //welcome back existing users
            string name = Request.QueryString["WB"];
            if (name != null)
            {
                Welcome.Text = "Welcome Back To Cheveux " + name;
            }
            else
            {
                //welcome new customers
                name = Request.QueryString["NU"];
                if (name != null)
                {
                    Welcome.Text = "Congratulations " + name
                                   + "  You Are Now Registered With Cheveux";
                }
            }
            #endregion

            #region booking Confirimation
            //confirm booking
            string   stylistID = Request.QueryString["Sty"];
            string   Date      = Request.QueryString["D"];
            string   slotNo    = Request.QueryString["T"];
            DateTime Time      = Convert.ToDateTime("2001/01/01");

            try
            {
                if (stylistID != null &&
                    Date != null &&
                    slotNo != null)
                {
                    List <SP_GetSlotTimes> TSL = handler.BLL_GetAllTimeSlots();
                    foreach (SP_GetSlotTimes TS in TSL)
                    {
                        if (TS.SlotNo.Replace(" ", string.Empty) == slotNo.Replace(" ", string.Empty))
                        {
                            Time = TS.Time;
                        }
                    }
                    Welcome.Text = "You are now booked to see "
                                   + handler.viewEmployee(stylistID.Replace(" ", string.Empty)).firstName
                                   + " at " + Time.ToString("HH:mm")
                                   + " on the " + Convert.ToDateTime(Date).ToString("dd MMM yyyy");
                }
            }
            catch (Exception err)
            {
                function.logAnError("unable to load booking confirmaton on default.aspx." +
                                    "stylist ID : " + stylistID +
                                    " | Date : " + Date +
                                    " | Slot No. : " + slotNo +
                                    " | Time : " + Time +
                                    " | CustID : " + UserID["ID"].ToString() +
                                    " | Error : " + err);
            }
            #endregion

            #region Home Page Features
            features = null;
            try
            {
                //get the home page featurs
                features = handler.GetHomePageFeatures();
            }
            catch (Exception err)
            {
                function.logAnError("unable to load featurd items from the DB on default.aspx: " +
                                    err);
            }

            #region Featured hairstyles
            try
            {
                LService1Header.Text = "<a class='btn btn-light' href='cheveux/services.aspx?ProductID=" +
                                       features[3].ItemID.ToString()
                                       + "'>" + features[3].Name.ToString() + "</a></font>";
                LService1Description.Text = features[3].description.ToString()
                                            + " from R" + features[3].price.ToString();

                LService2Header.Text = "<a class='btn btn-light' href='cheveux/services.aspx?ProductID=" +
                                       features[4].ItemID.ToString()
                                       + "'>" + features[4].Name.ToString() + "</a></font>";
                LService2Description.Text = features[4].description.ToString()
                                            + " from R" + features[4].price.ToString();

                LService3Header.Text = "<a class='btn btn-light' href='cheveux/services.aspx?ProductID=" +
                                       features[5].ItemID.ToString()
                                       + "'>" + features[5].Name.ToString() + "</a></font>";
                LService3Description.Text = features[5].description.ToString()
                                            + " from R" + features[5].price.ToString();

                LService4Header.Text = "<a class='btn btn-light' href='cheveux/services.aspx?ProductID=" +
                                       features[6].ItemID.ToString()
                                       + "'>" + features[6].Name.ToString() + "</a>";
                LService4Description.Text = features[6].description.ToString()
                                            + " from R" + features[6].price.ToString();
            }
            catch (Exception err)
            {
                function.logAnError("unable to display featured hairstyls on default.aspx: " +
                                    err);
            }
            #endregion

            #region Featured Products
            //Load Products
            try
            {
                phProductImage1.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[0].ItemID + ".jpg'/>"));
                lProductHeader1.Text      = features[0].Name.ToString();
                LProductDescription1.Text = features[0].description.ToString()
                                            + " from R" + features[0].price.ToString();

                phProductImage2.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[1].ItemID + ".jpg'/>"));
                lProductHeader2.Text      = features[1].Name.ToString();
                LProductDescription2.Text = features[1].description.ToString()
                                            + " from R" + features[1].price.ToString();

                phProductImage3.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[2].ItemID + ".jpg'/>"));
                lProductHeader3.Text      = features[2].Name.ToString();
                LProductDescription3.Text = features[2].description.ToString()
                                            + " from R" + features[2].price.ToString();
            }
            catch (Exception err)
            {
                function.logAnError("unable to display featured products on default.aspx: " +
                                    err);
            }
            #endregion

            #region Featured Stylists
            //Load Products
            try
            {
                phStylistImage1.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[4].ItemID + ".jpg'/>"));
                lStylistHeader1.Text      = features[7].firstName.ToString();
                lStylistDescription1.Text = "Specializes in "
                                            + handler.viewStylistSpecialisationAndBio(features[7].ItemID.ToString()).serviceName;

                phStylistImage2.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[8].ItemID + ".jpg'/>"));
                lStylistHeader2.Text      = features[8].firstName.ToString();
                lStylistDescription2.Text = "Specializes in "
                                            + handler.viewStylistSpecialisationAndBio(features[8].ItemID.ToString()).serviceName;

                phStylistImage3.Controls.Add(new LiteralControl
                                                 ("<img width='650' height='650' src='http://sict-iis.nmmu.ac.za/beauxdebut/Theam/img/" + features[9].ItemID + ".jpg'/>"));
                lStylistHeader3.Text      = features[9].firstName.ToString();
                lStylistDescription3.Text = "Specializes in "
                                            + handler.viewStylistSpecialisationAndBio(features[9].ItemID.ToString()).serviceName;
            }
            catch (Exception err)
            {
                function.logAnError("unable to display featured stylist on default.aspx: " +
                                    err);
            }
            #endregion

            #region Operating Hours
            try
            {
                //get the operating hourse from the db
                BUSINESS operatingHours = handler.getBusinessTable();
                //display the opperating hours

                //add hours - weekday
                lWeekdaye.Text = operatingHours.WeekdayStart.ToString("HH:mm") + " - " + operatingHours.WeekdayEnd.ToString("HH:mm");

                //add hours - weekend
                lWeekend.Text = operatingHours.WeekendStart.ToString("HH:mm") + " - " + operatingHours.WeekendEnd.ToString("HH:mm");

                //add hours - public holiday
                lPublicHol.Text = operatingHours.PublicHolStart.ToString("HH:mm") + " - " + operatingHours.PublicHolEnd.ToString("HH:mm");
            }
            catch (Exception err)
            {
                function.logAnError("unable to load operating hours on default.aspx: " +
                                    err);
            }
            #endregion
            #endregion
            #endregion
        }