Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C#, Create an interface for an employee salary calculator. When the employ

ID: 3579454 • Letter: U

Question

Using C#, Create an interface for an employee salary calculator. When the employee first walks up, the form will have the following:

1. A welcome label,

2. Two textboxes…one for them to enter their name and one to enter the password.

3. Two labels identifying the textbox

4. A button to Login

After the click on the Login button, the program should:

1. Check if the password is “XYZ”. If it is, then

a) the Welcome label should change to say “Type in your Information”

b) One of the labels should change to “Hours Worked”

c) One of the labels should change to “Pay Rate”

d) The Login button should disappear

e) A new “Calculate” button should appear

f) A third textbox below the calculate button should appear.

2. (Now the employee will be able to enter their pay info for the week in the textboxes).

a) After they click on the calculate button, your program should multiply the hours worked data with the pay rate data and display it in a user friendly fashion in the third textbox.

3. If the password wasn’t correct, an error message should appear, clear out the password entry and let them try again until they do it right.

The above problem gives you practice in designing an interface, declaring variables and constants, re-naming controls, accepting data from textboxes(converting if it is numeric), changing control properties within the code(visible, text, etc), writing If/Else code, and converting numeric data to string before displaying in a textbox.

Explanation / Answer

class Earning

{

    public int EmployeeID { get; set; }

    public string Name { get; set; }

    public decimal BasicSalaryAmount { get; set; }

    public decimal BudjetoryAllowance { get; set; }

    public int WorkDays { get; set; }

    public int DayOffs { get; set; }

    public int LeaveDays { get; set; }

    public int AbsentDays { get; set; }

    public int ExtraShifts { get; set; }

    public int NoPayDays { get; set; }

    public decimal LessNoPayAmount { get; set; }

    public decimal AmountForEPF { get; set; }

    public decimal OverTimeAmount { get; set; }

    public decimal IncentiveAllowance { get; set; }

    public decimal SpecialAllowance { get; set; }

    public decimal OtherAllowance { get; set; }

    public decimal ExtraShiftAmount { get; set; }

    public decimal BroughtForwardAmount { get; set; }

    public string Remarks { get; set; }

}

             class WageInfo

                {

                    public DateTime WagePeriodStartDate { get; private set; }

                    public DateTime WagePeriodEndDate { get; private set; }

                    public string Reference { get; private set; }

                    public Deduction Deduction;

                    public List<Deduction> DeductionList;

                    private Earning Earning;

                    private List<Earning> EarningList;

                    public WageBalance WageBalance;

                    public List<WageBalance> WageBalanceList;

                    public WageInfo()

                    {

                        Deduction = new Deduction();

                        DeductionList = new List<Payroll.Deduction>();

                        Earning = new Earning();

                        EarningList = new List<Payroll.Earning>();

                      WageBalance = new WageBalance();

                        WageBalanceList = new List<WageBalance>();

                    }

                    public Earning AddEarning(int employeeID, int workDays, int dayOffs, int leaveDays, int extraShifts, decimal extraShiftsAmount, decimal basicSalary, decimal budjetoryAllowance,

                        int noPayDays, decimal lessNoPayAmount, decimal amountForEpf, decimal overTimeAmount, decimal broughtForwardAmount, decimal incentiveAllowance, decimal otherAllowance, decimal specialAllowance)

                    {

                        Earning.EmployeeID = employeeID;

                        Earning.WorkDays = workDays;

                        Earning.DayOffs = dayOffs;

                        Earning.LeaveDays = leaveDays;

                        Earning.ExtraShifts = extraShifts;

                        Earning.BasicSalaryAmount = basicSalary;

                        Earning.BudjetoryAllowance = budjetoryAllowance;

                        Earning.NoPayDays = noPayDays;

                        Earning.LessNoPayAmount = lessNoPayAmount;

                        Earning.AmountForEPF = amountForEpf;

                        Earning.OverTimeAmount = overTimeAmount;

                        Earning.ExtraShiftAmount = extraShiftsAmount;

                        Earning.IncentiveAllowance = incentiveAllowance;

                        Earning.OtherAllowance = otherAllowance;

                        Earning.SpecialAllowance=specialAllowance;

                        Earning.BroughtForwardAmount = broughtForwardAmount;

                        return Earning;

                    }

                    public List<Earning> CreateEarningList(DataTable dt)

                    {

                        EarningList= dt.Rows.OfType<DataRow>().Select(InsertEarningsToList).ToList();

                        return EarningList;

                    }

                    private Earning InsertEarningsToList(DataRow row)

                    {

                        WageInfo wi = new WageInfo();

                        return wi.AddEarning(

                        row["Emp_ID"] == DBNull.Value ? 0 : Convert.ToInt32(row[0]),

                        row[2] == DBNull.Value ? 0 : Convert.ToInt32(row[2]),

                        row[3] == DBNull.Value ? 0 : Convert.ToInt32(row[3]),

                        row[4] == DBNull.Value ? 0 : Convert.ToInt32(row[4]),

                        row[5] == DBNull.Value ? 0 : Convert.ToInt32(row[5]),

                        row[7] == DBNull.Value ? 0 : Convert.ToDecimal(row[7]),

                        row[8] == DBNull.Value ? 0 : Convert.ToDecimal(row[8]),

                        row[9] == DBNull.Value ? 0 : Convert.ToDecimal(row[9]),

                        row[10] == DBNull.Value ? 0 : Convert.ToInt32(row[10]),

                        row[11] == DBNull.Value ? 0 : Convert.ToDecimal(row[11]),

                        row[12] == DBNull.Value ? 0 : Convert.ToDecimal(row[12]),

                        row[13] == DBNull.Value ? 0 : Convert.ToDecimal(row[13]),

                        row[14] == DBNull.Value ? 0 : Convert.ToDecimal(row[14]),

                        row[15] == DBNull.Value ? 0 : Convert.ToDecimal(row[15]),

                        row[16] == DBNull.Value ? 0 : Convert.ToDecimal(row[16]),

                        row[15] == DBNull.Value ? 0 : Convert.ToDecimal(row[17])

                        );

                    }

                    public Earning UpdateEarnings(int row)

                    {

                        return EarningList[row];

                    }

        class WageManager

            {

                WageInfo _WageInfo;

                DataService _DataService;

                public WageManager(WageInfo wageInfo, DataService dataService )

                {

                    _WageInfo = wageInfo;

                    _DataService = dataService;

                }

                # region Earning

                public List<Earning> PrepareEarnings(DateTime wagePeriodStartDate, DateTime wagePeriodEndDate)

                {

                    var info = _DataService.GetEarnings(wagePeriodStartDate, wagePeriodEndDate);

                    return _WageInfo.CreateEarningList(info);

                }

                public void UpdateEarnings(int row)

                {

                    _DataService.InsertEarnings( _WageInfo.UpdateEarnings(row));

                }

            }

     class WagesPresenter : BasePresenter

        {

            WageInfo _WageInfo;

            frmWages _WageView;

            WageManager _WageManager;

            BindingSource bS = new BindingSource();

            public WagesPresenter(WageManager wageManger, WageInfo wageInfo, frmWages wageView )

            {

                this._WageInfo = wageInfo;

                this._WageView = wageView;

                _WageManager = wageManger;

            }

    private void _WageView_OnProcessingEarnings(object sender, EventArgs e)

            {

                ShowEarnings();

            }

            private void ShowEarnings()

            {

                bS.DataSource = _WageManager.PrepareEarnings(_WageInfo.WagePeriodStartDate, _WageInfo.WagePeriodEndDate);

                _WageView.EarningDetails = bS;

            }

    }

class DataService

{

        public DataTable GetEarnings(DateTime fromDate, DateTime toDate)

        {

            using (SqlConnection sqlConnection = new SqlConnection(db.GetConnectionString))

            {

                using (SqlCommand sqlCommand = new SqlCommand("dbo.sp_Earnings", sqlConnection))

                {

                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.Add("@fromDate", SqlDbType.DateTime).Value = fromDate;

                    sqlCommand.Parameters.Add("@toDate", SqlDbType.DateTime).Value = toDate;

                    using (SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCommand))

                    {

                        using (DataSet dataSet = new DataSet())

                        using (DataTable dataTable = new DataTable())

                        {

                            sqlConnection.Open();

                            dataSet.Tables.Add(dataTable);

                            sqlAdapter.Fill(dataTable);

                            return dataTable;

                        }

                    }

                }

            }

        }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote