protected void BtnInvoiceSearch_Click(object sender, EventArgs e)
        {
            //Collects current method for error tracking
            string method = "BtnInvoiceSearch_Click";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //Binds invoice list to the grid view
                GrdInvoiceSelection.DataSource = IM.CallReturnInvoicesBasedOnSearchCriteria(CalStartDate.SelectedDate, CalEndDate.SelectedDate, txtInvoiceNum.Text, Convert.ToInt32(ddlLocation.SelectedValue), objPageDetails);
                GrdInvoiceSelection.DataBind();
                MergeRows(GrdInvoiceSelection);
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Collects current method and page for error tracking
            string method = "Page_Load";

            Session["currPage"] = "ReportsCOGSvsPM";
            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //checks if the user has logged in
                if (Session["currentUser"] == null)
                {
                    //Go back to Login to log in
                    Server.Transfer("LoginPage.aspx", false);
                }
                else
                {
                    CU = (CurrentUser)Session["currentUser"];
                    //Gathering the start and end dates
                    object[]   passing     = (object[])Session["reportInfo"];
                    DateTime[] reportDates = (DateTime[])passing[0];
                    DateTime   startDate   = reportDates[0];
                    DateTime   endDate     = reportDates[1];
                    locationID = (int)passing[1];
                    //Builds string to display in label
                    if (startDate == endDate)
                    {
                        lblDates.Text = "Cost of Goods Sold & Profit Margin on: " + startDate.ToString("dd/MMM/yy") + " for " + LM.CallReturnLocationName(locationID, objPageDetails);
                    }
                    else
                    {
                        lblDates.Text = "Cost of Goods Sold & Profit Margin on: " + startDate.ToString("dd/MMM/yy") + " to " + endDate.ToString("dd/MMM/yy") + " for " + LM.CallReturnLocationName(locationID, objPageDetails);
                    }
                    //Binding the gridview
                    inv = R.CallReturnInvoicesForCOGS(startDate, endDate, locationID, objPageDetails);
                    GrdInvoiceSelection.DataSource = inv;
                    GrdInvoiceSelection.DataBind();
                }
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Collects current method and page for error tracking
            string method = "Page_Load";

            Session["currPage"] = "CustomerAddNew.aspx";
            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //checks if the user has logged in
                if (Session["currentUser"] == null)
                {
                    //Go back to Login to log in
                    Response.Redirect("LoginPage.aspx", false);
                }
                else
                {
                    CU = (CurrentUser)Session["currentUser"];
                    //Checks for a Customer Key
                    if (Convert.ToInt32(Request.QueryString["customer"].ToString()) != -10)
                    {
                        if (!IsPostBack)
                        {
                            //Create customer class and fill page with all info based in the customer number
                            Customer customer = CM.CallReturnCustomerWithInvoiceList(Convert.ToInt32(Request.QueryString["customer"].ToString()), objPageDetails)[0];

                            txtFirstName.Text            = customer.varFirstName.ToString();
                            txtLastName.Text             = customer.varLastName.ToString();
                            txtPrimaryAddress.Text       = customer.varAddress.ToString();
                            txtSecondaryAddress.Text     = customer.secondaryAddress.ToString();
                            txtPrimaryPhoneNumber.Text   = customer.varContactNumber.ToString();
                            txtSecondaryPhoneNumber.Text = customer.secondaryPhoneNumber.ToString();
                            txtEmail.Text = customer.varEmailAddress.ToString();
                            txtCity.Text  = customer.varCityName.ToString();

                            DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails);
                            DdlCountry.DataBind();
                            DdlCountry.SelectedValue  = customer.intCountryID.ToString();
                            ddlProvince.DataSource    = LM.CallReturnProvinceDropDown(customer.intCountryID, objPageDetails);
                            ddlProvince.SelectedValue = customer.intProvinceID.ToString();
                            ddlProvince.DataBind();

                            txtPostalCode.Text   = customer.varPostalCode.ToString();
                            chkEmailList.Checked = customer.bitSendMarketing;

                            //Binds invoice list to the grid view
                            GrdInvoiceSelection.DataSource = customer.invoices;
                            GrdInvoiceSelection.DataBind();
                        }
                    }
                    else
                    {
                        //no cust number
                        if (!IsPostBack)
                        {
                            DdlCountry.DataSource = LM.CallReturnCountryDropDown(objPageDetails);
                            DdlCountry.DataBind();
                            DdlCountry.SelectedValue = CU.location.intCountryID.ToString();

                            ddlProvince.DataSource = LM.CallReturnProvinceDropDown(0, objPageDetails);
                            ddlProvince.DataBind();
                        }
                        //Displays text boxes instead of label for customer creation info
                        txtFirstName.Enabled            = true;
                        txtLastName.Enabled             = true;
                        txtPrimaryAddress.Enabled       = true;
                        txtSecondaryAddress.Enabled     = true;
                        txtPrimaryPhoneNumber.Enabled   = true;
                        txtSecondaryPhoneNumber.Enabled = true;
                        txtEmail.Enabled      = true;
                        txtCity.Enabled       = true;
                        ddlProvince.Enabled   = true;
                        DdlCountry.Enabled    = true;
                        chkEmailList.Enabled  = true;
                        txtPostalCode.Enabled = true;
                        //hides and displays the proper buttons for access
                        BtnSaveCustomer.Visible        = false;
                        BtnAddCustomer.Visible         = true;
                        pnlDefaultButton.DefaultButton = "btnAddCustomer";
                        BtnEditCustomer.Visible        = false;
                        BtnStartSale.Visible           = false;
                        BtnCancel.Visible       = false;
                        BtnBackToSearch.Visible = true;
                    }
                }
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }