private void btnsave_Click(object sender, EventArgs e)
        {
            Loan l = new Loan();
            l.empid = Global.CURRENT_USER.empid;
            l.principal = Convert.ToDecimal(txtprincipal.Text);
            l.interest = Convert.ToDecimal(txtinterest.Text);
            l.amortization_on_interest = Convert.ToDecimal(txtinterest_amort.Text);
            l.amortization_on_principal = Convert.ToDecimal(txtprincipal_amort.Text);
            l.loantype = LOAN_TYPE;
            l.amortization_period = (Int32)nmamortperiod.Value;
            l.filingdate = dtfilingdate.Value;

            if (l.save())
            {
                MessageBox.Show("Successful");
            }
            else
            {
                MessageBox.Show("There was a problem saving leave :\n" + db.err.Message);
            }
        }
Esempio n. 2
0
        private void cboemp_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtinterest.Text = "";
            txtinterest_amort.Text = "";
            cboprincipal.Text = "";
            txtprincipal_amort.Text = "";
            txttotal_amort.Text = "";
            MAXIMUM_ALLOWED_AMORT_PERIOD = 0;
            MAXIMUM_ALLOWED_LOAN = 0;
            txtbalance.Text = "";
            cbopayment_mode.Text = "";
            cbocollection_day.Text = "";
            cboamortization_period.Text = "";
            txtnetproceeds.Text = "";
            lbapplicantsdata.Items.Clear();
            lblatestloan.Items.Clear();
            lbcomakersdata.Items.Clear();
            lbcomakerslatestloan.Items.Clear();

            if (cboemp.Text != "")
            {
                String[] c = cboemp.Text.ToString().Split('-');
                String id = c[1];
                Employee emp2 = new Employee();
                emp2.empid = id;

               applicant = emp2.SELECT_BY_ID();

                //GET LATEST BASIC SAL
                decimal BASIC_PAY = applicant.GET_BASIC_PAY();

                //emp1.SELECT_BY_ID();
                applicant.GET_IMAGE_BY_ID();

                String pos = (applicant.GET_CURRENT_POSITION() != "") ? applicant.position.ToString() : "NO_POSITION_INDICATED";
                lblemp.Text = applicant.lname.ToUpper() + ", " + applicant.fname.ToUpper() + " " + applicant.mname.ToUpper() + " - " + pos;

                //WHEN WAS THE EMPLOYEE BECAME REGULAR?
                DateTime regularization_date = applicant.GET_REGULAR_STATUS_DATE();
                int months_as_regular = Global.GetMonths(regularization_date, DateTime.Now);

                //DISPLAY REGULARIZATION DATE
                lbapplicantsdata.Items.Add("EMPLOYEE INFORMATION");
                lbapplicantsdata.Items.Add("BECAME REGULAR SINCE :" + regularization_date.ToShortDateString());
                lbapplicantsdata.Items.Add("TOTAL MONTHS_IN_SEVICE AS REGULAR : " + months_as_regular.ToString());
                lbapplicantsdata.Items.Add("BASIC SALARY : " + BASIC_PAY.ToString("#,##0.00"));

                //DETERMINE HOW MUCH LOAN IS ALLOWED FOR THIS CERTAIN EMPLOYEE
                //ACCORDING TO HIS/HER BASIC PAY
                //MessageBox.Show(months_as_regular + " - " + BASIC_PAY.ToString());
                if ((months_as_regular >= 6) && (months_as_regular <= 12))
                {
                    MAXIMUM_ALLOWED_LOAN = 2 * BASIC_PAY;
                    MAXIMUM_ALLOWED_AMORT_PERIOD = 6;

                    iteratesalary(BASIC_PAY, cboprincipal, 2);

                }
                else if ((months_as_regular > 12) && (months_as_regular <= 24))
                {
                    MAXIMUM_ALLOWED_LOAN = 4 * BASIC_PAY;
                    MAXIMUM_ALLOWED_AMORT_PERIOD = 24;
                    iteratesalary(BASIC_PAY, cboprincipal, 4);
                }
                else if (months_as_regular > 24)
                {
                    MAXIMUM_ALLOWED_LOAN = 6 * BASIC_PAY;
                    MAXIMUM_ALLOWED_AMORT_PERIOD = 24;
                    iteratesalary(BASIC_PAY, cboprincipal, 6);

                }

                //display latest loan

                l.empid = applicant.empid;

                Loan applicant_latest_loan = l.GET_LATEST_LOAN("SALARY");
                PREV_LOAN = applicant_latest_loan;
                // GET THE LATEST MICRO LOAN OF A MEMBER
                lblatestloan.Items.Add("LATEST MICRO LOAN");
                LATEST_SALARY_LOAN = (applicant_latest_loan != null) ? applicant_latest_loan.principal : 0;

                if (LATEST_SALARY_LOAN != 0)
                {
                    lblatestloan.Items.Add("APPLICATION NO : " + applicant_latest_loan.application_no);
                    lblatestloan.Items.Add("PRINCIPAL : PhP " + applicant_latest_loan.principal.ToString("#,##0.00"));
                    lblatestloan.Items.Add("INTEREST : PhP " + applicant_latest_loan.interest.ToString("#,##0.00"));
                    lblatestloan.Items.Add("MONTHLY AMORTIZATION: PhP " + (applicant_latest_loan.amortization_on_interest + applicant_latest_loan.amortization_on_principal).ToString("#,##0.00"));
                    lblatestloan.Items.Add("BALANCE: ---(under development)---");
                }
                else {
                    lblatestloan.Items.Add("Nothing found...");
                    lblatestloan.Items.Add("MAXIMUM ALLOWED LOAN :" + MAXIMUM_ALLOWED_LOAN.ToString("#,##0.00"));
                    lblatestloan.Items.Add("MAXIMUM AMORTIZATION PERIOD :" + MAXIMUM_ALLOWED_AMORT_PERIOD.ToString());
                }

                cboprincipal.Text = MAXIMUM_ALLOWED_LOAN.ToString("0.00");
               // lblloancategory.Text = "MAXIMUM_ALLOWED_AMOUNT : " + MAXIMUM_ALLOWED_LOAN.ToString("#,##0.00") + " MAXIMUM_AMORTIZATION_PERIOD : " + MAXIMUM_ALLOWED_AMORT_PERIOD.ToString();
                //nmamortperiod.Maximum = MAXIMUM_ALLOWED_AMORT_PERIOD;
                //nmamortperiod.Value = nmamortperiod.Maximum;

                if (applicant.pic != null)
                {
                    MemoryStream ms = new MemoryStream(applicant.pic);
                    pb.Image = Image.FromStream(ms);
                    pb.SizeMode = PictureBoxSizeMode.Zoom;
                }
                else
                {
                    pb.Image = Properties.Resources.noimagefound;
                    pb.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
        }
Esempio n. 3
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            Loan nl = new Loan();
            nl.application_no = lblapplicationno.Text;
            //its okey EMPID and MEMID are treated same way in database.
            nl.empid = applicant.empid;
            nl.comakerid = comaker.empid;
            nl.principal = Convert.ToDecimal(cboprincipal.Text);
            nl.interest = Convert.ToDecimal(txtinterest.Text);
            nl.amortization_period = (int)SELECTED_AMORTIZATION;
            nl.amortization_on_principal = Convert.ToDecimal(txtprincipal_amort.Text);
            nl.amortization_on_interest = Convert.ToDecimal(txtinterest_amort.Text);
            nl.loantype = "SALARY";
            nl.payment_period = cbopayment_mode.Text;
            nl.collection_day = cbocollection_day.Text;
            nl.auto_credit_to_cbu = 0;
            nl.net_proceeds = Convert.ToDecimal(txtnetproceeds.Text);
            nl.prev_loan_application_no = (PREV_LOAN != null) ? PREV_LOAN.application_no : "";

            if (nl.save())
            {
                l.INCREASE_SALARY_LOAN_COUNTER();
                MessageBox.Show("Successful");
                btncancel.PerformClick();
            }
            else
            {
                MessageBox.Show("There was a problem saving your SALARY_LOAN_APPLICATION :");
            }
        }
Esempio n. 4
0
        private void cboMem_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtinterest.Text = "";
            txtinterest_amort.Text = "";
            txtprincipal.Text = "";
            txtprincipal_amort.Text = "";
            txttotal_amort.Text = "";
            cbocollection_day.Text = "";
            cbopayment_mode.Text = "";
            txtinterest.Text = "";
            cboamortization_period.Text = "";
            MAXIMUM_ALLOWED_LOAN = 0;

            lbmembersdata.Items.Clear();
            lblatestloan.Items.Clear();
            cboComaker.Text = "";
            pbcomaker.Image = null;
            lblcomaker.Text = "";
            lblcomaker.BackColor = Color.Transparent;
            lbcomakersdata.Items.Clear();
            lbcomakerslatestloan.Items.Clear();

            if (cboMem.Text != "")
            {
                String[] c = cboMem.Text.ToString().Split('-');
                String id = c[c.Length-2] + "-" + c[c.Length-1];

                Member m2 = new Member();
                //MessageBox.Show(id);
                m2.memid = id;
                applicant = m2.SELECT_BY_ID();
                m2.GET_IMAGE_BY_ID();

                lblmem.Text = applicant.fullname.ToString().ToUpper() + " - " + applicant.occupation.ToString();

                Member_Capital mc = new Member_Capital();
                mc.memid = applicant.memid;

                decimal cbu = mc.GET_CURRENT_PAID_UP_CAPITAL();

                lbmembersdata.Items.Add("MEMBER'S VERIFICATION DATA");
                lbmembersdata.Items.Add("MEMBER SINCE : " + applicant.acceptance_date.ToShortDateString());
                lbmembersdata.Items.Add("MEMBER STANDING : " + applicant.standing);
                lbmembersdata.Items.Add("CBU AS OF " + DateTime.Now.ToShortDateString() + " : PhP " + cbu.ToString("#,##0.00"));

                l.empid = applicant.memid;

                Loan applicant_latest_loan = l.GET_LATEST_LOAN("MICRO");
                PREV_LOAN = applicant_latest_loan;
                // GET THE LATEST MICRO LOAN OF A MEMBER
                lblatestloan.Items.Add("LATEST MICRO LOAN");
                LATEST_MICRO_LOAN = (applicant_latest_loan != null) ? applicant_latest_loan.principal : 0;

                if (LATEST_MICRO_LOAN != 0) {

                    lblatestloan.Items.Add("APPLICATION NO : " + applicant_latest_loan.application_no);
                    lblatestloan.Items.Add("PRINCIPAL : PhP " + applicant_latest_loan.principal.ToString("#,##0.00"));
                    lblatestloan.Items.Add("INTEREST : PhP " + applicant_latest_loan.interest.ToString("#,##0.00"));
                    lblatestloan.Items.Add("MONTHLY AMORTIZATION: PhP " + (applicant_latest_loan.amortization_on_interest + applicant_latest_loan.amortization_on_principal).ToString("#,##0.00"));
                    lblatestloan.Items.Add("BALANCE: ---(under development)---");
                }
                else
                {

                    lblatestloan.Items.Add("Nothing found...");

                }

                //lblmemdata2.Text = "CAPITAL BUILD-UP :" +cbu.ToString("#,##0.00");

                if (cbu >= MINIMUM_SHARED_CAPITAL_TO_AVAIL_LOAN)
                {
                    lbmembersdata.Items.Add("PASSED THE MINIMUM : " + MINIMUM_SHARED_CAPITAL_TO_AVAIL_LOAN.ToString("#,##0.00") + " SHARE TO AVAIL LOAN");
                    lblmem.BackColor = Color.Green;

                    //subtract minimum shared capital from the CBU
                    //then get the 60% -- because 60% of (CBU-MINIMUM_SHARED_CAPITAL) is the
                    //LOANABLE_AMOUNT
                    MAXIMUM_ALLOWED_LOAN = (cbu - MINIMUM_SHARED_CAPITAL) * PERCENTAGE_TOGET_LOANABLE_AMOUNT;
                    lbmembersdata.Items.Add("MAX LOANABLE AMOUNT : PhP " + MAXIMUM_ALLOWED_LOAN.ToString("#,##0.00"));

                }
                else {

                    lbmembersdata.Items.Add("DID NOT PASSED THE MINIMUM : " + MINIMUM_SHARED_CAPITAL_TO_AVAIL_LOAN.ToString("#,##0.00") + " SHARE TO AVAIL LOAN");
                    lblmem.BackColor = Color.Red;
                }

                if (m2.pic != null)
                {
                    MemoryStream ms = new MemoryStream(m2.pic);
                    pb.Image = Image.FromStream(ms);
                    pb.SizeMode = PictureBoxSizeMode.Zoom;
                }
                else
                {
                    pb.Image = Properties.Resources.noimagefound;
                    pb.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
        }
Esempio n. 5
0
        public void LoadLoansInListView(ListView lv)
        {
            Loan e = new Loan();
            DataTable dt = new DataTable();

            dt = e.SELECT_ALL();
            if (dt != null)
            {
                int ctr = 1;
                foreach (DataRow r in dt.Rows)
                {
                    ListViewItem li = new ListViewItem();
                    li.Text = ctr.ToString();
                    li.SubItems.Add(r["empid"].ToString());
                    li.SubItems.Add(r["principal"].ToString());
                    li.SubItems.Add(r["interest"].ToString());
                    //amortization on interest
                    decimal amointe = Convert.ToDecimal(r["amortization_on_interest"].ToString());
                    //amortization on principal
                    decimal amoprin = Convert.ToDecimal(r["amortization_on_principal"].ToString());

                    li.SubItems.Add((amoprin + amoprin).ToString("#,##0.00"));

                    li.SubItems.Add(r["amortization_period"].ToString());

                    li.SubItems.Add(r["loantype"].ToString());

                    lv.Items.Add(li);
                    ctr++;

                }
            }
        }
Esempio n. 6
0
        public Loan GET_LATEST_LOAN(String type_of_loan)
        {
            DataTable dt = new DataTable();
            MySqlCommand cmd = new MySqlCommand();
            db.SET_COMMAND_PARAMS(cmd, "LOAN_SELECT_LATEST_BYTYPE");
            cmd.Parameters.AddWithValue("_loantype", type_of_loan);
            cmd.Parameters.AddWithValue("_empid", empid);

            MySqlDataAdapter da = new MySqlDataAdapter(cmd);

            try
            {
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    DataRow r = dt.Rows[0];
                    Loan l = new Loan();
                    l.empid = r["empid"].ToString();
                    l.application_no =r["application_no"].ToString();
                    l.principal = Convert.ToDecimal(r["principal"].ToString());
                    l.interest = Convert.ToDecimal(r["interest"].ToString());
                    l.amortization_on_principal = Convert.ToDecimal(r["amortization_on_principal"].ToString());
                    l.amortization_on_interest = Convert.ToDecimal(r["amortization_on_interest"].ToString());
                    l.auto_credit_to_cbu = Convert.ToDecimal(r["auto_credit_to_cbu"].ToString());
                    l.net_proceeds = Convert.ToDecimal(r["net_proceeds"].ToString());

                    return l;

                }
                else {
                    return null;
                }
            }
            catch (Exception e)
            {
                Logger.WriteErrorLog(e.Message);
                return null;
            }
        }