Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys i have problem

this code send email based on timer every 5 minutes

it working ok but my problem i need to determine first rcord updated not inserted

and send email this is starting work

this is my code

timer1_Tick
C#
Sales.SalesClass SalesClass1 = new Sales.SalesClass();
DataTable dt = SalesClass1.ShowSalesData("Data Source=192.168.1.5;Initial Catalog=Altawi-last06-01-2015;User ID=admin;Password=123");
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
------
namespace Sales
{
class SalesClass
{
public DataTable ShowSalesData(string ConnectionString)
{
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "showsales1";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables[0];
return dt;
}
}
}
}


SQL
SELECT     ROW_NUMBER() OVER (ORDER BY dbo.[Jeddah-Live$Sales Header].No_) AS [م], dbo.[Jeddah-Live$Sales Line].[Document No_] AS 'رقم الطلب', 
dbo.[Jeddah-Live$Sales Header].[Bill-to Name] AS 'العميل', dbo.[Jeddah-Live$Sales Line].Area AS 'نوع الصبه', dbo.[Jeddah-Live$Sales Line].Description AS 'البيان', 
dbo.[Jeddah-Live$Sales Header].[Pump No_] AS 'المضخه', CAST(ROUND(dbo.[Jeddah-Live$Sales Line].Quantity, 0, 1) AS int) AS 'المطلوب', 
CAST(ROUND(dbo.[Jeddah-Live$Sales Line].[Quantity Shipped], 0, 1) AS int) AS 'المصبوب', CAST(ROUND(dbo.[Jeddah-Live$Sales Line].[Outstanding Quantity], 0, 
1) AS int) AS 'المتبقى '
FROM         dbo.[Jeddah-Live$Sales Header] INNER JOIN
                      dbo.[Jeddah-Live$Sales Line] ON dbo.[Jeddah-Live$Sales Header].No_ = dbo.[Jeddah-Live$Sales Line].[Document No_] AND 
                      dbo.[Jeddah-Live$Sales Header].[Sell-to Customer No_] = dbo.[Jeddah-Live$Sales Line].[Sell-to Customer No_]

------------
The code above not have any problem and working
When first record updated send email

Example to show

orderno   quantity  shipped quantity

12            20               0

13            30               0

14            25               0

15           22                0


suppose order no 14 shipped quantity updated be 10 (meaning 0 be 10

then send email with starting work

after this any updated to any record not send

no problem i dont need any send email code but how to get record updated first
Posted
Updated 27-Mar-15 16:12pm
v2
Comments
You have not posted the Update codes. If you use ExecuteNonQuery(), then Update query would return you the number of records updated.
ahmed_sa 28-Mar-15 3:38am    
Thank you for reply
I don't have update statement because it made by dynamic nav solutions 2009
but only what i need actually send email when first increment of shipped quantity happen
to refer that work start after this i don't need to send email after any increment
if possible can any one help me in this task

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