private void btnAddToList_Click(object sender, EventArgs e)
        {
            string PayToID = MyCommon.GetSelectedID(cmbPayTo, true);


            decimal fullamount = 0, ExchageBalanceAmountLKR = 0;
            bool    resp = decimal.TryParse(txttotalAmount.Text, out fullamount);

            foreach (DataGridViewRow r in dgvBillList.Rows)
            {
                string curreny1 = MyAccount.GetAccountCurrenyType(r.Cells["dgvBillList_AccID"].Value.ToString());
                if (curreny1 == lblCurrentcy.Text.Trim())
                {
                    if (chkAutoFill.Checked)
                    {
                        decimal onelineamount = 0;
                        resp = decimal.TryParse(r.Cells["dgvBillList_Cr"].Value.ToString(), out onelineamount);
                        decimal remain = fullamount - onelineamount;



                        if ((fullamount > onelineamount) || (fullamount == onelineamount))
                        {
                            r.Cells["dgvBillList_CurPayment"].Value = r.Cells["dgvBillList_Cr"].Value.ToString();
                            r.Cells["dgvBillList_Select"].Value     = "1";
                            fullamount = remain;
                        }
                        else
                        {
                            r.Cells["dgvBillList_CurPayment"].Value = fullamount.ToString("##0.00");
                            r.Cells["dgvBillList_Select"].Value     = "1";
                            chkAutoFill.Checked = false;
                        }
                    }
                    if (r.Cells["dgvBillList_Select"].Value.ToString() == "1")
                    {
                        int  Lref = 0;
                        bool res  = int.TryParse(lblLRef.Text, out Lref);
                        if (Lref == 0)
                        {
                            Lref = dgvAccList.RowCount + 1;
                        }
                        decimal LKR    = 0;
                        decimal USD1   = 0;
                        decimal ExRate = 0;

                        bool rsp = decimal.TryParse(r.Cells["dgvBillList_CurPayment"].Value.ToString(), out USD1);
                        rsp = decimal.TryParse(txtExRate.Text, out ExRate);
                        decimal payiedExrate = 0, DiffrenceRate = 0;
                        rsp = decimal.TryParse(r.Cells["dgvBillList_Exrate"].Value.ToString(), out payiedExrate);

                        int Index1 = ExistAutoTable(r.Cells["dgvBillList_Bill"].Value.ToString());

                        LKR = USD1 * payiedExrate;

                        if (payiedExrate != ExRate)
                        {
                            DiffrenceRate           = ExRate - payiedExrate;
                            ExchageBalanceAmountLKR = ExchageBalanceAmountLKR + (DiffrenceRate * USD1);
                            ExRate = payiedExrate;
                        }


                        if (Index1 != -1)
                        {
                            dgvAccList.Rows[Index1].Cells[2].Value = "Payment of " + r.Cells["dgvBillList_Bill"].Value.ToString();
                            dgvAccList.Rows[Index1].Cells[3].Value = r.Cells["dgvBillList_Bill"].Value.ToString();
                            dgvAccList.Rows[Index1].Cells[4].Value = "";
                            dgvAccList.Rows[Index1].Cells[5].Value = LKR.ToString("##0.00");
                            dgvAccList.Rows[Index1].Cells[6].Value = USD1.ToString("##0.00");
                        }
                        else
                        {
                            string   AcName  = MyAccount.GetAccountName(r.Cells["dgvBillList_AccID"].Value.ToString());
                            string[] Oneline = { r.Cells["dgvBillList_AccID"].Value.ToString(), AcName, "Payment of " + r.Cells["dgvBillList_Bill"].Value.ToString(), r.Cells["dgvBillList_Bill"].Value.ToString(), "", LKR.ToString("##0.00"), USD1.ToString("##0.00"), payiedExrate.ToString("##0.00"), GetNextLinNumber("dgvAccList_Ref") };
                            dgvAccList.Rows.Add(Oneline);
                        }
                    }
                }
                else
                {
                    Program.VerningMessage("Currency type miss match");
                }
            }
            if (ExchageBalanceAmountLKR > 0)
            {
                string   GetExGainID = MyAccount.GetExchangeGainAccount();
                string   AcName      = MyAccount.GetAccountName(GetExGainID);
                string[] Oneline     = { GetExGainID, AcName, "Exchange Gain ", "", "", ExchageBalanceAmountLKR.ToString("##0.00"), "0.00", "1", GetNextLinNumber("dgvAccList_Ref") };
                dgvAccList.Rows.Add(Oneline);
            }
            else
            {
                ExchageBalanceAmountLKR = ExchageBalanceAmountLKR * -1;
                string   GetExLossID = MyAccount.GetExchangeLossAccount();
                string   AcName      = MyAccount.GetAccountName(GetExLossID);
                string[] Oneline     = { GetExLossID, AcName, "Exchange Loss ", "", "", ExchageBalanceAmountLKR.ToString("##0.00"), "0.00", "1", GetNextLinNumber("dgvAccList_Ref") };
                dgvAccList.Rows.Add(Oneline);
            }
            CalTotalLine();
            panel14.Visible = false;
        }