Esempio n. 1
0
        private ReportPO getMatchedInvoiceDetails(List <ReportPO> InvoiceDetailList, ReportPO POrpo)
        {
            ReportPO matchedRIO = new ReportPO();

            if (party == 1)
            {
                matchedRIO = InvoiceDetailList.FirstOrDefault(rpoio => (rpoio.PartyID == POrpo.PartyID) && (rpoio.DocumentType == POrpo.DocumentType));
                if (matchedRIO != null)
                {
                    int index = InvoiceDetailList.FindIndex(rpoio => (rpoio.PartyID == POrpo.PartyID) && (rpoio.DocumentType == POrpo.DocumentType));
                    matchedIOIndexList.Add(index);
                }
            }
            else if (region == 1)
            {
                matchedRIO = InvoiceDetailList.FirstOrDefault(rpoio => (rpoio.RegionID == POrpo.RegionID) && (rpoio.DocumentType == POrpo.DocumentType));
                if (matchedRIO != null)
                {
                    int index = InvoiceDetailList.FindIndex(rpoio => (rpoio.RegionID == POrpo.RegionID) && (rpoio.DocumentType == POrpo.DocumentType));
                    matchedIOIndexList.Add(index);
                }
            }
            else
            {
                matchedRIO = InvoiceDetailList.FirstOrDefault(rpoio => (rpoio.DocumentType == POrpo.DocumentType));
                if (matchedRIO != null)
                {
                    int index = InvoiceDetailList.FindIndex(rpoio => (rpoio.DocumentType == POrpo.DocumentType));
                    matchedIOIndexList.Add(index);
                }
            }


            return(matchedRIO);
        }
Esempio n. 2
0
 private void addItemsInGridDetail(List <ReportPO> PODetailList, List <ReportPO> InvoiceDetailList)
 {
     try
     {
         grdDetailList.Rows.Clear();
         matchedIOIndexList.Clear();
         int    i            = 1;
         double totalPOValue = 0;
         double totalIOValue = 0;
         foreach (ReportPO rpo in PODetailList)
         {
             double   InvValue  = 0;
             ReportPO matchedIO = getMatchedInvoiceDetails(InvoiceDetailList, rpo);
             if (matchedIO != null)
             {
                 InvValue = matchedIO.Value;
             }
             else
             {
                 InvValue = 0;
             }
             grdDetailList.Rows.Add();
             //grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value = i;
             grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POType"].Value = rpo.DocumentType;
             if (party == 1)
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gParty"].Value = rpo.Name; // For party name
             }
             else if (region == 1)
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gRegion"].Value = rpo.Name;  // For region Name
             }
             //else
             //    grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gRegion"].Value = rpo.Name;  // For region Name
             if (rdbNormal.Checked == true)
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = rpo.Value;
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = InvValue;
             }
             else if (rdbThousands.Checked == true)
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = rpo.Value / 1000;
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = InvValue / 1000;
             }
             else if (rdbLakhs.Checked == true)
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = rpo.Value / 100000;
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = InvValue / 100000;
             }
             else
             {
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = rpo.Value;
                 grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = InvValue;
             }
             totalPOValue = totalPOValue + Convert.ToDouble(grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value);
             totalIOValue = totalIOValue + Convert.ToDouble(grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value);
             i++;
         }
         if (InvoiceDetailList.Count != matchedIOIndexList.Count)
         {
             int track = 0;
             for (track = 0; track < InvoiceDetailList.Count; track++)
             {
                 if (!matchedIOIndexList.Contains(track))
                 {
                     ReportPO matchedIO = InvoiceDetailList[track];
                     grdDetailList.Rows.Add();
                     //grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value = i;
                     grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POType"].Value = matchedIO.DocumentType;
                     if (party == 1)
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gParty"].Value = matchedIO.Name; // For party name
                     }
                     else if (region == 1)
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["gRegion"].Value = matchedIO.Name;  // For region Name
                     }
                     if (rdbNormal.Checked == true)
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = 0;
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = matchedIO.Value;
                     }
                     else if (rdbThousands.Checked == true)
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = 0;
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = matchedIO.Value / 1000;
                     }
                     else if (rdbLakhs.Checked == true)
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = 0;
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = matchedIO.Value / 100000;
                     }
                     else
                     {
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value      = 0;
                         grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value = matchedIO.Value;
                     }
                     totalPOValue = totalPOValue + Convert.ToDouble(grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["POValue"].Value);
                     totalIOValue = totalIOValue + Convert.ToDouble(grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InvoiceValue"].Value);
                 }
             }
         }
         if (rdbLakhs.Checked == true)
         {
             txtTotalPOValue.Text      = totalPOValue.ToString("F2");
             txtTotalInvoiceValue.Text = totalIOValue.ToString("F2");
             grdDetailList.Columns["POValue"].DefaultCellStyle.Format      = "N2";
             grdDetailList.Columns["InvoiceValue"].DefaultCellStyle.Format = "N2";
         }
         else
         {
             txtTotalPOValue.Text      = totalPOValue.ToString("F0");
             txtTotalInvoiceValue.Text = totalIOValue.ToString("F0");
             grdDetailList.Columns["POValue"].DefaultCellStyle.Format      = "N0";
             grdDetailList.Columns["InvoiceValue"].DefaultCellStyle.Format = "N0";
         }
         if (chkRegionWise.Checked == false && chkPartWise.Checked == false)
         {
             grdDetailList.Columns["POType"].Width = 400;
         }
         if (chkRegionWise.Checked == true || chkPartWise.Checked == true)
         {
             grdDetailList.Columns["gParty"].Width  = 300;
             grdDetailList.Columns["gRegion"].Width = 300;
             grdDetailList.Columns["POType"].Width  = 100;
         }
         if (chkRegionWise.Checked == true)
         {
             grdDetailList.Sort(grdDetailList.Columns["gRegion"], System.ComponentModel.ListSortDirection.Ascending);
         }
         else if (chkPartWise.Checked == true)
         {
             grdDetailList.Sort(grdDetailList.Columns["gParty"], System.ComponentModel.ListSortDirection.Ascending);
         }
         foreach (DataGridViewRow row in grdDetailList.Rows)
         {
             row.Cells["LineNo"].Value = row.Index + 1;
         }
     }
     catch (Exception ex)
     {
     }
 }