Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Application["Province"] = "Ontario"; //temporary setting of Province Variable

        _employeeID = (int)Session["EmployeeID"];
        _startTime  = (DateTime)Session["StartDate"];
        _endTime    = (DateTime)Session["EndDate"];


        double employeePayRate = ConnectionClass.FindCurrentPayRate(_employeeID);


        listOfInfo = ConnectionClass.FindShifts(_employeeID);
        Employee employee = ConnectionClass.GetEmployeeInfo(_employeeID);

        List <PaystubInfo> refinedList = createListOfValidPaystubInfo(listOfInfo);

        CalculateFromPaystubInfo(refinedList);


        string prov = Application["Province"].ToString();

        CPP       = TaxManagement.CalculateCPP(_grossPay, true);
        IncomeTax = TaxManagement.CalculateIncomeTax(_grossPay, prov, true);
        EI        = TaxManagement.CalculateEmploymentInsurance(_grossPay, true);



        _netPay = _grossPay - (EI + IncomeTax + CPP);

        FullHoursTextBox.Text     = _totalHours.ToString();
        GrossPayTextBox.Text      = String.Format("{0:c}", _grossPay);
        RegularHoursTextBox.Text  = _regularHours.ToString();
        OvertimeHoursTextBox.Text = _overtimeHours.ToString();
        NetPayTextBox.Text        = String.Format("{0:c}", _netPay);
        PayRateTextBox.Text       = String.Format("{0:c}", employee.PayRate);
        NameLabel.Text            = employee.FirstName + " " + employee.LastName;
        SSnLabel.Text             = "***-***-" + employee.SocialNumber.ToString().Substring(6, 3);
        IDLabel.Text                  = _employeeID.ToString();
        PayPeriodLabel.Text           = _startTime.ToString() + "---" + _endTime.ToString();
        IncomeTaxTextBox.Text         = String.Format("{0:c}", IncomeTax);
        CPPTextBox.Text               = String.Format("{0:c}", CPP);
        EITextBox.Text                = String.Format("{0:c}", EI);
        OverallDeductionsTextbox.Text = String.Format("{0:c}", IncomeTax + CPP + EI);
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ITaxResult TaxResultObj = null;

        try
        {
            Cart         CartObj        = new JavaScriptSerializer().Deserialize <Cart>(CookieProxy.Instance().GetValue("Cart").ToString());
            IAddress     AddressObj     = new Address(int.Parse(Request.Form["aid"].ToString()));
            IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
            TaxResultObj = new TaxManagement().CalculateTaxFromCartItems(CartObj, AddressObj, UserProfileObj);
        }
        catch (Exception)
        {
            TaxResultObj = new TaxResult(false);
        }
        finally
        {
            var ResultObj = new
            {
                Response = TaxResultObj
            };
            Response.Write(new JavaScriptSerializer().Serialize(ResultObj));
        }
    }
Ejemplo n.º 3
0
        protected void AcceptButton_Click(object sender, EventArgs e)
        {
            try
            {
                startTime = Begin_Calendar.SelectedDate;
                endTime   = End_Calendar.SelectedDate;

                string   employeeID         = Employee_ID_Textbox.Text;
                string   averageHoursWorked = AverageHoursTextBox.Text;
                string   averageShiftsAWeek = AverageShiftsTextBox.Text;
                Employee employee           = ConnectionClass.GetEmployeeInfo(Convert.ToInt32(employeeID));

                int id                 = 0;
                int hoursWorked        = 0;
                int averageShiftNumber = 0;

                if (int.TryParse(employeeID, out id) == true &&
                    int.TryParse(averageHoursWorked, out hoursWorked) == true &&
                    int.TryParse(averageShiftsAWeek, out averageShiftNumber) == true &&
                    startTime != DateTime.MinValue &&
                    endTime != DateTime.MinValue && employee != null && employee.Active == 1)
                {
                    int.TryParse(employeeID, out id);
                    int.TryParse(averageHoursWorked, out hoursWorked);
                    int.TryParse(averageShiftsAWeek, out averageShiftNumber);


                    double employeePayRate = ConnectionClass.FindCurrentPayRate(id);

                    //Needed to calculate tax info for custom timeframe
                    double yearlyGrossIncome = (hoursWorked * averageShiftNumber * employeePayRate) * 52;


                    listOfInfo = ConnectionClass.FindShifts(id);

                    List <PaystubInfo> refinedList = createListOfValidPaystubInfo(listOfInfo);
                    CalculateGrossPayForExtendedPeriod(refinedList);

                    //Calculating appropriate tax for chosen time frame

                    double percentageOfYear = _shiftCount / 365;

                    Application["Province"] = "Ontario";
                    string prov = Application["Province"].ToString();

                    //yearly tax
                    double baseIncomeTax = TaxManagement.CalculateIncomeTax(yearlyGrossIncome, prov, false);
                    double baseCpp       = TaxManagement.CalculateCPP(yearlyGrossIncome, false);
                    double baseEI        = TaxManagement.CalculateEmploymentInsurance(yearlyGrossIncome, false);

                    //Altering for timeframe chosen
                    double incomeTax = baseIncomeTax * percentageOfYear;
                    double Cpp       = baseCpp * percentageOfYear;
                    double eI        = baseEI * percentageOfYear;

                    double allDeductions = incomeTax + eI + Cpp;

                    double netIncome = _grossPay - allDeductions;

                    //Populating Textboxes:
                    GrossPayTextBox.Text        = string.Format("{0:C}", _grossPay);
                    TotalHourWorkedTextbox.Text = string.Format("{0}", _totalHours);
                    PayRateTextBox.Text         = string.Format("{0:C}", employeePayRate);
                    TotalShiftsTextbox.Text     = string.Format("{0}", _shiftCount);
                    PayPeriodTextbox.Text       = startTime.ToString() + "---" + endTime.ToString();
                    EITextbox.Text        = string.Format("{0:C}", eI);
                    CPPTextbox.Text       = string.Format("{0:C}", Cpp);
                    IncomeTaxTextbox.Text = string.Format("{0:C}", incomeTax);
                    NetPayTextbox.Text    = string.Format("{0:C}", netIncome);

                    Session["Gross"]             = _grossPay;
                    Session["totalHours"]        = _totalHours;
                    Session["overtimeHours"]     = _overtimeHours;
                    Session["regularHours"]      = _regularHours;
                    Session["payRate"]           = employeePayRate;
                    Session["shiftCount"]        = _shiftCount;
                    Session["timeFrame"]         = startTime.ToString() + "---" + endTime.ToString();
                    Session["ei"]                = eI;
                    Session["cpp"]               = Cpp;
                    Session["incomeTax"]         = incomeTax;
                    Session["netPay"]            = netIncome;
                    Session["overallDeductions"] = allDeductions;
                    Session["employee"]          = employee;

                    ResultsPanel.Visible = true;

                    errorLabel.Text = "";
                }

                else
                {
                    errorLabel.Text = "Please enter a valid time and Employee ID";
                }
            }

            catch (Exception ex)
            {
                errorLabel.Text = ex.Message;
            }
        }