private void btnSave_Click_1(object sender, EventArgs e)
        {
            if(txtAge.Text == "" || txtContactNo.Text == "" || txtFname.Text == "" || txtLname.Text =="" || txtAddress.Text == "" || txtContactNo.Text == ""){
                MessageBox.Show("Please supply the required fields.");
                return;
            }
            if(txtlengthservice.Text == ""){
                txtlengthservice.Text = "0";
            }
            cl_moneylender cMoneyLender = new cl_moneylender();
            cl_LenderInformation l_Info = new cl_LenderInformation();
            cMoneyLender.propfname = txtFname.Text;
            cMoneyLender.proplname = txtLname.Text;
            cMoneyLender.propMI = txtMI.Text;
            cMoneyLender.propAddress = txtAddress.Text;
            cMoneyLender.propAge = Convert.ToInt32(txtAge.Text);
            cMoneyLender.propCreditLimit = Convert.ToDouble(222);
            cMoneyLender.propLenderID = txtMoneyLenderID.Text;
            cMoneyLender.propContact_no = txtContactNo.Text;
            cMoneyLender.propIs_inactive = cboLenderType.Text;

            l_Info.propLengthofService = Convert.ToInt32(txtlengthservice.Text.ToString());
            l_Info.propHouseType = cbohousetype.Text;
            l_Info.propGender = cboGender.Text;
            l_Info.propEmail = txtemail.Text;
            l_Info.propOccupation  = txtoccupation.Text;
            l_Info.propPosition = txtposition.Text;
            l_Info.propTIN_no = txtTin_no.Text;
            l_Info.propCompanyName = txtcompanyname.Text;
            l_Info.propCompanyAdd = txtcompanyaddress.Text;
            l_Info.propCivilStatus = cboCivilStatus.Text;
            l_Info.propbirthplace = txtbirthplace.Text;
            l_Info.propDOB = dob.Value;

            cl_spouse sp = new cl_spouse();

            sp.propspousename  = txtspousename.Text;
            sp.propspouseOcc = txtSoCCu.Text;
            sp.propsCompany =txtsCompany.Text;
            sp.propsPosition=txtspouseP.Text;

            //check if is active or not
            cl_borrower_loan bl = new cl_borrower_loan();

            if (cboCivilStatus.Text != "Single")
            {
               sp.props_age = Convert.ToInt32(txtSpouseAge.Text);
            }
            if (cMoneyLender.propAge < 18 )
            {
                MessageBox.Show("Age should not lesser than 18");
                return;
            }
            if (PUBLIC_VARS.EDITMODE == true){

                cMoneyLender.UPDATE_DATA(mlt);

                int l_sid = Convert.ToInt32(PUBLIC_VARS.d.getlastid().ToString());
                l_Info.propmonenylenderInfoID = l_sid;
                l_Info.INSERT_DATATOLENDER();
                if (cboCivilStatus.Text != "Single")
                {
                    sp.propMoneyLender_id = l_sid;
                    sp.UPDATE_SPOUSE(mlt);

                }
                cMoneyLender.propMoneyLender_id = mlt;

                if (InsertPictureBarrowerImages == "")
                {
                    cMoneyLender.propPicBarrower = tempPictures;
                }
                else
                {
                    cMoneyLender.propPicBarrower = InsertPictureBarrowerImages;
                }
                cMoneyLender.UpdatePicBarrower();
                MessageBox.Show( PUBLIC_VARS.updateData);
            }
            else{
                MYFUNCTIONS f = new MYFUNCTIONS();

                if (cMoneyLender.isBarrowerExist() == true) {
                    MessageBox.Show("Record already exist.");
                    return;
                }

                cMoneyLender.INSERT_DATA();
                int iiiD = PUBLIC_VARS.d.getlastid();
                int l_sid = Convert.ToInt32(PUBLIC_VARS.d.getlastid().ToString());
                l_Info.propmonenylenderInfoID = l_sid;
                l_Info.INSERT_DATATOLENDER();
                if(cboCivilStatus.Text != "Single"){
                    sp.propMoneyLender_id = l_sid;
                    sp.INSERT_SPOUSE();

                }

                Int64 dx = f.autoUserID() + 1;

                f.InsertCounterNo(dx);

                if (InsertPictureBarrowerImages == ""){
                    InsertPictureBarrowerImages = "default_avatar.jpg";
                }

                cMoneyLender.propPicBarrower = InsertPictureBarrowerImages;
                cMoneyLender.propMoneyLender_id = iiiD;
                cMoneyLender.InserPictureBarrower();

                MessageBox.Show(PUBLIC_VARS.saveData);

            }
            //cMoneyLender.LOAD_MONEYLENDER(lst.lsvMoneyLender);
            //MYFUNCTIONS m = new MYFUNCTIONS();
            //string sql = "SELECT * FROM tmoneylender";
            //m.PopulateListView(lsvevent,sql);
            cMoneyLender.LOAD_MONEYLENDER(lsvevent);
            this.Close();
        }
        private void btnProcess_Click(object sender, EventArgs e)
        {
            cl_lender_inform lenderIn = new cl_lender_inform();
            try
            {
                if (lenderIn.PEND_ACTIVELOAN(mYLenderIDs) == true)
                {
                    MessageBox.Show("Please settle your loan first. " );

                }
                else
                {
                    cl_lender_inform lend = new cl_lender_inform();
                    cl_borrower_loan bl = new cl_borrower_loan();
                   // int ml_ID = Convert.ToInt32(lsvLender.SelectedItems[0].Text);

                     List<DateTime> lstq = new List<DateTime>();

                    for (int i = 0; i < lstamt.Count; i++)
                    {
                        lend.propDbalance = lstamt[i];
                        //lend.propiTerest =    ;
                        //    lend.propPrinc = ;
                        lend.propMnt_amount = Convert.ToDouble(txtMonthlyDue.Text);
                        lend.propLoan_id = 2;
                        lend.propStatus = "Pending";
                        lend.propMoneyLender_id = mYLenderIDs;
                        lend.propPrinc = Convert.ToDouble(lsvPaymentSched.Items[i].SubItems[2].Text);
                        lend.propSchedate = Convert.ToDateTime(lsvPaymentSched.Items[i].Text.ToString());
                        lend.propHpenalty = 0.0;
                        lend.propBalanceAmount = Convert.ToDouble(lsvPaymentSched.Items[i].SubItems[3].Text);
                        lend.INSERT_LENDER_INFORM(); // tschedule_of_payment

                        //bl.propRemarks = "Pending";
                        //bl.propBorrowerID = mYLenderIDs;
                        //bl.propSchedate =Convert.ToDateTime(lsvPaymentSched.Items[i].Text.ToString());
                        //bl.propAmountLend = Convert.ToDouble(txtAmountApplied.Text);

                        //bl.InsertCustLoan();  // tmoneylender_loan
                    }
                    bl.propRemarks = "Pending";
                    bl.propBorrowerID = mYLenderIDs;
                    bl.propSchedate = DateTime.Today; //Convert.ToDateTime(lsvPaymentSched.Items[i].Text.ToString());
                    bl.propAmountLend = Convert.ToDouble(txtAmountApplied.Text);
                    bl.InsertCustLoan();  // tmoneylender_loan
                    MessageBox.Show("Loan has been approve.");
                    this.Hide();
                }
            }
            catch(Exception ex){
                MessageBox.Show(ex.Message);
            }
        }