private void frmListMoneyLender_Load(object sender, EventArgs e)
 {
     cl_moneylender cMoneyLender = new cl_moneylender();
     cMoneyLender.LOAD_MONEYLENDER(lsvMoneyLender);
     //MYFUNCTIONS m = new MYFUNCTIONS();
     //string sql = "select * from tmoneylender";
     //m.PopulateListView(lsvMoneyLender, sql);
 }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lsvMoneyLender.SelectedItems.Count > 0)
            {

                PUBLIC_VARS.activeID = Convert.ToInt32(lsvMoneyLender.SelectedItems[0].Text.ToString());
                cl_moneylender cMoneyLender = new cl_moneylender();
                DialogResult result1 = MessageBox.Show("Are you sure you want to delete entry?", "delete", MessageBoxButtons.YesNo);
                if (result1 == DialogResult.Yes)
                {
                    cMoneyLender.DELETE_DATA(PUBLIC_VARS.activeID);
                    MessageBox.Show(PUBLIC_VARS.deleteData);
                }
                cMoneyLender.LOAD_MONEYLENDER(lsvMoneyLender);
            }
            else {
                MessageBox.Show("No records to be deleted.");
            }
        }
        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();
        }