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(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)