Click here to Skip to main content
14,271,310 members
Rate this:
Please Sign up or sign in to vote.
See more:
Main Table data:
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.
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:
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100