Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Main Table data:
SQL
SELECT INVOICENO,
AllocatedTo,AllocatedToDeliveryOwner,Email_AllocatedTo,Email_AllocatedToDeliveryOwner FROM abctable 


in the above table invoice will be unique, other columns may be having duplicate values and null as well.

My requirement:
Need to share the all related invoices details to the persons (AllocatedTo,AllocatedToDeliveryOwner)in mail.
C#
static void Main(string[] args)
        {
            LongPendingCollectionAlertBL objBL = new LongPendingCollectionAlertBL();         
            DataTable  dtResultInvoices = objBL.InvoicesDetailsBL();
            if (dtResultInvoices.Rows.Count > 0)
            {
                Mailcontent(dtResultInvoices);
            }
        }
 public static void Mailcontent(DataTable dtResultInvoices)
        {
	 DataView view = new DataView(dtResultInvoices);
            DataTable distinctValues = view.ToTable(true, "AllocatedTo", "AllocatedToDeliveryOwner", "Email_AllocatedTo", "Email_AllocatedToDeliveryOwner");
            foreach (DataRow row in distinctValues.Rows)
            {
		DataRow[] foundRows = dtResultInvoices.Select("AllocatedTo = '" + row["AllocatedTo"].ToString().Trim() + "' AND AllocatedToDeliveryOwner = '" + row["AllocatedToDeliveryOwner"].ToString().Trim() + "' ");
		string Email_AllocatedTo = row["Email_AllocatedTo"].ToString();
                string Email_AllocatedToDeliveryOwner = row["Email_AllocatedToDeliveryOwner"].ToString();
                if (!string.IsNullOrEmpty(Email_AllocatedTo) || !string.IsNullOrEmpty(Email_AllocatedToDeliveryOwner))
                    strmailto = Email_AllocatedTo + "," + Email_AllocatedToDeliveryOwner;
                else
                {
                    strmailto = strmailcc;
                }

            }



the above code is working, if both allocatedto and allocateddeliveryowner are present (returning the related invoices(records) in 'foundRows'), if any one columns is having null, returning zero invoices(records) in 'foundRows'


so my concern is here i want fetch all related invoices based on allocatedto and allocatedtodeliveryowner columns

What I have tried:

sample table data:
SQL
InvoiceNo	AllocatedTo	AllocatedToDeliveryOwner	Email_AllocatedTo	Email_AllocatedToDeliveryOwner
0121203	8345	15387	kar@u.com	na.buur@u.com
1103438	9999234	NULL	who@u.com	NULL
0221807	8021	NULL	anna@u.com	NULL
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900