protected void fillIncomingInvGrid(ArrayList invList)
        {
            String[] contactEntId = Request.QueryString.GetValues("contactId");

            if (invList == null || invList.Count == 0)
            {
                invList = BackEndObjects.Invoice.getAllInvoicesbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("rfqId");
            dt.Columns.Add("InvId");
            dt.Columns.Add("InvNo");
            dt.Columns.Add("totalAmnt");
            dt.Columns.Add("InvDate");
            dt.Columns.Add("pmntStat");
            dt.Columns.Add("totalPending");

            DateUtility dU = new DateUtility();

            int rowCount = 0;

            for (int i = 0; i < invList.Count; i++)
            {
                BackEndObjects.Invoice invObj = (BackEndObjects.Invoice)invList[i];

                if (invObj.getRespEntityId().Equals(contactEntId[0]))
                {
                    float totalPendingAmnt = 0;
                    float totalClearedAmnt = 0;

                    Dictionary <String, Payment> pmntDict = BackEndObjects.Payment.getPaymentDetailsforInvoiceDB(invObj.getInvoiceId());

                    foreach (KeyValuePair <String, Payment> kvp in pmntDict)
                    {
                        BackEndObjects.Payment pmntObj = kvp.Value;

                        totalClearedAmnt += pmntObj.getClearingStat().Equals(BackEndObjects.Payment.PAYMENT_CLEARING_STAT_CLEAR) ?
                                            pmntObj.getAmount() : 0;
                    }

                    totalPendingAmnt = invObj.getTotalAmount() - totalClearedAmnt;

                    dt.Rows.Add();
                    dt.Rows[rowCount]["rfqId"]        = invObj.getRFQId();
                    dt.Rows[rowCount]["InvId"]        = invObj.getInvoiceId();
                    dt.Rows[rowCount]["InvNo"]        = invObj.getInvoiceNo() != null && !invObj.getInvoiceNo().Equals("") ? invObj.getInvoiceNo() : invObj.getInvoiceId();
                    dt.Rows[rowCount]["totalAmnt"]    = invObj.getTotalAmount();
                    dt.Rows[rowCount]["InvDate"]      = dU.getConvertedDate(invObj.getInvoiceDate().Substring(0, invObj.getInvoiceDate().IndexOf(" ")));
                    dt.Rows[rowCount]["pmntStat"]     = invObj.getPaymentStatus();
                    dt.Rows[rowCount]["totalPending"] = totalPendingAmnt;

                    rowCount++;
                }
            }

            GridView_Incoming_Invoices.Visible    = true;
            GridView_Incoming_Invoices.DataSource = dt;
            GridView_Incoming_Invoices.DataBind();
            GridView_Incoming_Invoices.SelectedIndex = -1;
            Session[SessionFactory.ALL_CONTACT_ALL_DEAL_INCOMING_INV_GRID]      = dt;
            Session[SessionFactory.ALL_CONTACT_ALL_DEAL_INCOMING_INV_ARRAYLIST] = invList;
        }
 protected void GridView_Incoming_Invoices_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridView_Incoming_Invoices.PageIndex  = e.NewPageIndex;
     GridView_Incoming_Invoices.DataSource = (DataTable)Session[SessionFactory.ALL_CONTACT_ALL_DEAL_INCOMING_INV_GRID];
     GridView_Incoming_Invoices.DataBind();
 }