Click here to Skip to main content
15,068,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a unique id with the calling of the last data in the database. what if the data last empty?

public static void NewDemand(FilterDemand newDemandData)
        {
            using (WMS.DAL.WarehouseLinqDataContext dc = new WMS.DAL.WarehouseLinqDataContext())
            {
                WMS.DAL.Demand Demand = new WMS.DAL.Demand();
                DemandData DemandD = new DemandData();
                List<DemandData> listDemand = new List<DemandData>();
                var log = from de in dc.Demands
                          group de by new { de.ID_Demand } into result
                          select new
                          {
                              id1 = result.Key.ID_Demand,
                              id2 = result.Select(i => i.ID_Demand),
                              y = result.Select(i => i.Year)
                          };

                foreach (var d in log)
                {
                    DemandD.IDDemand = d.id2.Last();
                    listDemand.Add(DemandD);
                }

                string al = DemandD.IDDemand;
                int x = 0;
                string _val1 = al.Substring(1, al.Length - 5);
                x = Convert.ToInt32(_val1) + 1;
                string ff = "";
                ff = "D" + x;
                
                Demand.Month = newDemandData.FilterMonth;
                        Demand.ID_Demand = "D1";
                        Demand.GF = (float)newDemandData.FilterGF;
                        Demand.IND = (float)newDemandData.FilterIndoor;
                        Demand.Year = (int)newDemandData.FilterYear;
                        Demand.Total = Demand.GF + Demand.IND;
                        dc.Demands.InsertOnSubmit(Demand);
                        dc.SubmitChanges();
                
                }
            }
Posted
Comments
Sergey Alexandrovich Kryukov 26-Jun-12 20:14pm
   
And?
--SA
[no name] 26-Jun-12 21:17pm
   
what shoul I do if the last data is empty???
Wonde Tadesse 26-Jun-12 20:25pm
   
Not clear. Elaborate!
[no name] 26-Jun-12 21:18pm
   
what?
ssd_coolguy 27-Jun-12 8:12am
   
your question is not clear...
can you explain more..what actually you want to do..
[no name] 27-Jun-12 11:38am
   
if the last data is empty

1 solution

As a final step, check to see if the last row is empty. If it is, DELETE it.
   
Comments
[no name] 27-Jun-12 2:06am
   
what shoul I do if the last data is empty???

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