Beispiel #1
0
        public PensionerUser PensionerInfo(string eid)
        {
            DataTable     dt  = com.DefaultSearch("Pensioner", "EmployeID", eid);
            PensionerUser pen = new PensionerUser(dt);

            return(pen);
        }
Beispiel #2
0
        public bool UpdateRetirement(PensionerUser pu)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();
                dt.Columns.Add();

                dt.Rows.Add(new object[] { pu.Id, pu.Addition, pu.FinalReserve, pu.PensionRate, pu.Pension1 });

                bool s1 = mem.InsertPensioner(dt);

                DataTable du = new DataTable();
                du.Columns.Add();
                du.Columns.Add();
                du.Columns.Add();
                du.Columns.Add();

                du.Rows.Add(new object[] { pu.Type, pu.Pension1, pu.RetirementDate, pu.Id });
                bool s2 = mem.UpdateRetiredEmployee(du);

                return(s1 && s2);
            }
            catch (Exception ee) {
                MessageBox.Show(ee.ToString());
                return(false);
            }
        }
Beispiel #3
0
        public PensionerUser PensionCal(DateTime penregdate, DateTime retdate, double salary)
        {
            try
            {
                Rate     r     = new Rate();
                DateTime ds    = penregdate;
                DateTime dr    = retdate;
                TimeSpan t     = dr - ds;
                int      years = t.Days / 365;

                int type;


                if (years >= 30)
                {
                    r.Id = 3;
                    type = 2;
                }
                else if (years >= 25)
                {
                    r.Id = 2;
                    type = 2;
                }
                else if (years >= 20)
                {
                    r.Id = 1;
                    type = 2;
                }
                else
                {
                    r.Id = 5;
                    type = 3;
                }

                //Database sql
                DataTable dt = com.DefaultSearch("Rates", "ID", r.Id);
                r.Rate1 = Convert.ToDouble(dt.Rows[0][2].ToString());
                PensionerUser pu = new PensionerUser();

                pu.PensionRate = r.Rate1;

                pu.Type    = type;
                pu.Pension = r.Rate1 * salary;
                return(pu);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
                return(null);
            }
        }
Beispiel #4
0
        public PensionerUser ReserveCal(DateTime retdate, int type, double totalcontribution)
        {
            try
            {
                Rate      r  = new Rate();
                DataTable dt = com.DefaultSearch("Rates", "ID", "4");
                r.Rate1 = Convert.ToDouble(dt.Rows[0][2].ToString());


                DateTime dr = retdate;
                DateTime n  = DateTime.Now.Date;

                TimeSpan t       = n - dr;
                int      latency = Convert.ToInt32(t.Days);

                double Addition;                                //Calculations

                //MessageBox.Show("Latency is "+latency.ToString()+" Rate is " + rate.ToString() + " Addition is " + Addition.ToString());


                if (type == 2)
                {
                    Addition = totalcontribution * latency * r.Rate1 / 365;
                    Addition = Math.Round(Addition, 2);
                }
                else
                {
                    Addition = 0;
                    Addition = Math.Round(Addition, 2);
                }

                PensionerUser pu           = new PensionerUser();
                double        FinalReserve = totalcontribution + Addition;
                pu.Addition     = Addition;
                pu.FinalReserve = FinalReserve;
                pu.AdditionRate = r.Rate1;
                return(pu);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
                return(null);
            }
        }
Beispiel #5
0
 public void PensionRateCal()
 {
     if (RetDate.Value.Year > DateTime.Now.Year || (RetDate.Value.Month > DateTime.Now.Month && RetDate.Value.Year == DateTime.Now.Year))
     {
         MessageBox.Show("Do not Enter Future Periods");
         return;
     }
     try
     {
         PensionerUser pp = mem.PensionCal(DateTime.ParseExact(l5.Text.ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture), RetDate.Value, Convert.ToDouble(lBSalary.Text));
         lPension.Text            = pp.Pension.ToString();
         l10.Text                 = pp.PensionRate.ToString();
         typeselect.SelectedValue = pp.Type.ToString();
         Refresh();
     }
     catch (Exception ee) {
         MessageBox.Show(ee.ToString());
     }
 }
Beispiel #6
0
        public void ReserveCal()
        {
            if (RetDate.Value.Year > DateTime.Now.Year || (RetDate.Value.Month > DateTime.Now.Month && RetDate.Value.Year == DateTime.Now.Year))
            {
                MessageBox.Show("Do not Enter Future Periods");
                return;
            }
            try
            {
                PensionerUser pu = mem.ReserveCal(RetDate.Value, Convert.ToInt32(typeselect.SelectedValue.ToString()), Convert.ToDouble(l6.Text.ToString()));

                l8.Text = pu.Addition.ToString();
                l9.Text = pu.FinalReserve.ToString();
                l7.Text = pu.AdditionRate.ToString();
                Refresh();
            }
            catch (Exception ee) {
                MessageBox.Show(ee.ToString());
            }
        }
Beispiel #7
0
        private void Update_Click(object sender, EventArgs e)
        {
            try
            {
                PensionerUser pu = new PensionerUser(l1.Text.ToString(), Convert.ToDouble(l8.Text.ToString()), Convert.ToDouble(l9.Text.ToString()), Convert.ToDouble(l10.Text.ToString()), Convert.ToDouble(lPension.Text.ToString()));
                pu.Type           = Convert.ToInt32(typeselect.SelectedValue.ToString());
                pu.RetirementDate = RetDate.Value;
                if (mem.UpdateRetirement(pu))
                {
                    MessageBox.Show("Update Successful");
                }
                else
                {
                    MessageBox.Show("Update Failed");
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }