public static PlanFact GetByID(int id) { using (var context = new CMER_DWEnt()) { PlanFact qr = context.PlanFact.Include("Dic_Kpved").Include("Dic_Kato").Include("Dic_Kato1").Include("Dic_Kato2").Include("Dic_Kato2") .Include("Dic_ContragentsCl").Include("Dic_ContragentsCl1").Include("Dic_ContragentsCl1").Include("Dic_TypePlanFact").Include("Dic_Source") .SingleOrDefault(x => x.IDFact == id); //.OrderBy(x => x.DateStart).Skip(rows * (page - 1)). return qr; } }
public IQueryable<vwPlanFactLists> PlanFactLists() { //For NHibernate with Linq: // var query = Session.Linq<Computer>().AsQueryable(); using (var context = new CMER_DWEnt()) { return context.vwPlanFactLists.AsQueryable(); } //return new List<vwPlanFactLists>() //{ // new vwPlanFactLists(), // new vwPlanFactLists(), // new vwPlanFactLists(), // new vwPlanFactLists() //}.AsQueryable(); }
public PlanFact_All() { r = new PlanFact(); e = new PlanFact_Err(); using (var context = new CMER_DWEnt()) { Dic_Kpved = context.Dic_Kpved.Take(10).ToList<Dic_Kpved>(); Dic_Mkee = context.Dic_Mkee.Take(10).ToList<Dic_Mkee>(); Dic_Kato = context.Dic_Kato.Take(10).ToList<Dic_Kato>(); Dic_ContragentsCl = new List<CMER.Dic_ContragentsCl>(); //context.Dic_ContragentsCl.ToList<Dic_ContragentsCl>(); Dic_Source = context.Dic_Source.Take(10).ToList<Dic_Source>(); Dic_TypePlanFact = context.Dic_TypePlanFact.Take(10).ToList<Dic_TypePlanFact>(); Dic_Skp = context.Dic_Skp.Take(10).ToList<Dic_Skp>(); Dic_Certificates = context.Dic_Certificates.Take(10).ToList<Dic_Certificates>(); Dic_Ens = context.Dic_Ens.Take(10).ToList<Dic_Ens>(); Dic_Tnved = context.Dic_Tnved.Take(10).ToList<Dic_Tnved>(); Dic_CertificatesDetail = context.Dic_CertificatesDetail.Take(10).ToList<Dic_CertificatesDetail>(); Dic_Countries = context.Dic_Countries.Take(10).ToList<Dic_Countries>(); } }
internal static int GetAllErrCount() { using (var context = new CMER_DWEnt()) { var qr = context.PlanFact_Err.Count(); return qr; } }
internal static int GetAllCount() { using (var context = new CMER_DWEnt()) { var qr = context.PlanFact.Select(p => p.IDFact).Count(); return qr; } }
public static string SaveRawValue(string column, int rowID, int value) { using (var context = new CMER_DWEnt()) { PlanFact pf = context.PlanFact.Where(x => x.IDFact == rowID).FirstOrDefault(); if (pf != null) { if (column == "Qty") pf.Qty = value; if (column == "Volume") pf.Volume = value; context.Entry(pf).CurrentValues.SetValues(pf); } context.SaveChanges(); return ""; } }
public static PlanFact Update(PlanFact model) { using (var context = new CMER_DWEnt()) { var m = context.PlanFact.SingleOrDefault(x => x.IDFact == model.IDFact); if (m == null) return model; m.Qty = model.Qty ?? m.Qty; m.Volume = model.Volume ?? m.Volume; m.IDKatoDelivery = model.IDKatoDelivery ?? m.IDKatoDelivery; m.IDKatoPurchaser = model.IDKatoPurchaser ?? m.IDKatoPurchaser; m.IDKatoSupplier = model.IDKatoSupplier ?? m.IDKatoSupplier; m.IDMkee = model.IDMkee ?? m.IDMkee; m.IDKpved = model.IDKpved ?? m.IDKpved; //context.SaveChanges(); return m; } }
public static string SaveRaw(string column, int rowID, int id) { using (var context = new CMER_DWEnt()) { PlanFact pf = context.PlanFact.Where(x => x.IDFact == rowID).FirstOrDefault(); if (pf != null) { if (column == "kpvedName") pf.IDKpved = id; if (column == "ctgSName") pf.IDContragentSupplier = id; if (column == "ctgPName") pf.IDContragentPurchaser= id; if (column == "katoSName") pf.IDKatoSupplier = id; if (column == "katoPName") pf.IDKatoPurchaser = id; if (column == "mkeeName") pf.IDMkee = id; if (column == "skpName") pf.IDSkp = id; if (column == "countrySName") pf.IdCountrySupplier = id; if (column == "countryPName") pf.IdCountryPurchaser = id; if (column == "truType") pf.IDKpvedTRU = id; if (column == "srcName") pf.IDSource = id; context.Entry(pf).CurrentValues.SetValues(pf); } context.SaveChanges(); return ""; } }
public static string SaveRawDate(string column, int rowID, DateTime date) { using (var context = new CMER_DWEnt()) { PlanFact pf = context.PlanFact.Where(x => x.IDFact == rowID).FirstOrDefault(); if (pf != null) { if (column == "DateStart") pf.DateStart = date; if (column == "DateEnd") pf.DateEnd = date; context.Entry(pf).CurrentValues.SetValues(pf); } context.SaveChanges(); return ""; } }
public static List<PlanFact> GetList(int page, int rows) { using (var context = new CMER_DWEnt()) { context.Configuration.ProxyCreationEnabled =false; var qr = context.PlanFact .OrderBy(x => x.IDFact).Skip(rows * (page - 1)) .Take(rows); return qr.ToList<PlanFact>(); } }
public static List<vwPlanFactLists> GetListView(int page, int rows) { using (var context = new CMER_DWEnt()) { var qr = context.vwPlanFactLists .OrderBy(x => x.IDFact).Skip(rows * (page - 1)) .Take(rows); return qr.ToList<vwPlanFactLists>(); } }
public static List<Dic_Kpved> GetKpvedList(int page, int rows) { using (var context = new CMER_DWEnt()) { var qr = context.Dic_Kpved.Take(rows); //.OrderBy(x => x.DateStart).Skip(rows * (page - 1)). return qr.ToList<Dic_Kpved>(); } }
public static List<PlanFact_Err> GetErrList(int page, int rows) { using (var context = new CMER_DWEnt()) { // var qr = PagingUtils.Page<PlanFact_Err>(context.PlanFact_Err, rows, page); var qr = context.PlanFact_Err.OrderBy(x => x.IDFact).Skip(rows * (page - 1)).Take(rows); return qr.ToList<PlanFact_Err>(); } }
public static PlanFact_Err GetErrByID(int id) { using (var context = new CMER_DWEnt()) { PlanFact_Err qr = context.PlanFact_Err.SingleOrDefault(x => x.IDFact == id); //.OrderBy(x => x.DateStart).Skip(rows * (page - 1)). return qr; } }
public static Object GetDicList(string Name, string search, int rows,int page, int selid) { using (var context = new CMER_DWEnt()) { int skip = rows * (page - 1); List<object> obj = new List<object>(); if (Name == "IDKpved") { obj.AddRange(context.Dic_Kpved.Where(x => x.Name_1.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2, Descr = x.Descr, Unioncheck = x.Unioncheck }).ToList()); if (selid != 0) obj.Add(context.Dic_Kpved.Where(x => x.ID == selid).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2, Descr = x.Descr, Unioncheck = x.Unioncheck }).SingleOrDefault()); } else if (Name == "IDMkee") { obj.AddRange(context.Dic_Mkee.Where(x => x.Name_1.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2 }).ToList()); if (selid != 0) obj.Add(context.Dic_Mkee.Where(x => x.ID == selid).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2 }).SingleOrDefault()); } else if (Name == "IDKato") { obj.AddRange(context.Dic_Kato.Where(x => x.Name_1.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2, tempParent = x.tempParent }).ToList()); if (selid != 0) obj.Add(context.Dic_Kato.Where(x => x.ID == selid).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2, tempParent = x.tempParent }).SingleOrDefault()); } else if (Name == "IDContragents") { obj.AddRange(context.Dic_ContragentsCl.Where(x => x.NameRu.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, name = x.NameRu, NameKz = x.NameKz, Phones = x.Phones, FIOLeader = x.FIOLeader }).ToList()); if (selid != 0) obj.Add(context.Dic_ContragentsCl.Where(x => x.ID == selid).Take(rows).Select(x => new { ID = x.ID, name = x.NameRu, NameKz = x.NameKz, Phones = x.Phones, FIOLeader = x.FIOLeader }).SingleOrDefault()); } else if (Name == "IDSource") { obj.AddRange(context.Dic_Source.Where(x => x.Name.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, name = x.Name }).ToList()); if (selid != 0) obj.Add(context.Dic_Source.Where(x => x.ID == selid).Select(x => new { ID = x.ID, name = x.Name }).SingleOrDefault()); } else if (Name == "IDTypePlanFact") return context.Dic_TypePlanFact.Where(x => x.Name.Contains(search)).Take(rows).Select(x => new { ID = x.ID, name = x.Name }).ToList(); else if (Name == "IDSkp") { obj.AddRange(context.Dic_Skp.Where(x => x.Label.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, PlanFact = x.PlanFact, Kpved = x.Kpved, name = x.NameRu }).ToList()); if (selid != 0) obj.Add(context.Dic_Skp.Where(x => x.ID == selid).Select(x => new { ID = x.ID, Label = x.Label, PlanFact = x.PlanFact, Kpved = x.Kpved, name = x.NameRu }).SingleOrDefault()); } else if (Name == "IDCertificates") return context.Dic_Certificates.Where(x => x.Наименование_экспортера_рус.Contains(search)).Take(rows).Select(x => new { ID = x.ID, name = x.Наименование_экспортера_рус, www = x.www, email = x.email }).ToList(); else if (Name == "IDEns") return context.Dic_Ens.Where(x => x.Label.Contains(search)).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, Kpved = x.Kpved, name = x.Name_1 }).ToList(); else if (Name == "IDTnved") return context.Dic_Tnved.Where(x => x.Label.Contains(search)).Take(rows).Select(x => new { ID = x.ID, Label = x.Label, name = x.Name_1, Name_2 = x.Name_2, ImportDuty = x.ImportDuty }).ToList(); else if (Name == "IDCertificatesDetail") return context.Dic_CertificatesDetail.Where(x => x.Наименование_товара_рус.Contains(search)).Take(rows).Select(x => new { ID = x.ID, name = x.Наименование_товара_рус, FilePath = x.FilePath, IDCertificate = x.IDCertificate, RowNumber = x.RowNumber }).ToList(); else if (Name == "IDCountries") return context.Dic_Countries.Where(x => x.Names.Contains(search)).Take(rows).Select(x => new { Id = x.Id, name = x.Names, IsDeleted = x.IsDeleted, ModifiedDate = x.ModifiedDate }).ToList(); else if (Name == "IDTRUType") { obj.AddRange(context.Dic_TRUType.Where(x => x.Descr.Contains(search)).OrderBy(x => x.ID).Skip(skip).Take(rows).Select(x => new { ID = x.ID, name = x.Descr }).ToList()); if (selid != 0) obj.Add(context.Dic_TRUType.Where(x => x.ID == selid).Select(x => new { ID = x.ID, name = x.Descr }).SingleOrDefault()); } return obj; } }
public static Object GetDicHead(string Name, string search) { var rows = 10; using (var context = new CMER_DWEnt()) { List<object> obj = new List<object>(); if (Name == "IDKpved") obj.AddRange(context.Dic_Kpved.Where(x => x.Name_1.Contains(search)).Take(rows).Select(x => new { id = x.Name_1, name = x.Name_1 }).ToList()); else if (Name == "IDMkee") obj.AddRange(context.Dic_Mkee.Where(x => x.Name_1.Contains(search)).Take(rows).Select(x => new { id = x.Name_1, name = x.Name_1 }).ToList()); else if (Name == "IDKato") obj.AddRange(context.Dic_Kato.Where(x => x.Name_1.Contains(search)).Take(rows).Select(x => new { id = x.Name_1, name = x.Name_1 }).ToList()); else if (Name == "IDContragents") obj.AddRange(context.Dic_ContragentsCl.Where(x => x.NameRu.Contains(search)).Take(rows).Select(x => new { id = x.NameRu, name = x.NameRu }).ToList()); else if (Name == "IDSource") obj.AddRange(context.Dic_Source.Where(x => x.Name.Contains(search)).Take(rows).Select(x => new { id = x.Name, name = x.Name }).ToList()); else if (Name == "IDTypePlanFact") return context.Dic_TypePlanFact.Where(x => x.Name.Contains(search)).Take(rows).Select(x => new { id = x.Name, name = x.Name }).ToList(); else if (Name == "IDSkp") obj.AddRange(context.Dic_Skp.Where(x => x.Label.Contains(search)).Take(rows).Select(x => new { id = x.NameRu, name = x.NameRu }).ToList()); else if (Name == "IDCertificates") return context.Dic_Certificates.Where(x => x.Наименование_экспортера_рус.Contains(search)).Take(rows).Select(x => new { id = x.ID, name = x.Наименование_экспортера_рус }).ToList(); else if (Name == "IDEns") return context.Dic_Ens.Where(x => x.Label.Contains(search)).Take(rows).Select(x => new { id = x.Name_1, name = x.Name_1 }).ToList(); else if (Name == "IDTnved") return context.Dic_Tnved.Where(x => x.Label.Contains(search)).Take(rows).Select(x => new { id = x.Name_1, name = x.Name_1 }).ToList(); else if (Name == "IDCertificatesDetail") return context.Dic_CertificatesDetail.Where(x => x.Наименование_товара_рус.Contains(search)).Take(rows).Select(x => new { id = x.Наименование_товара_рус, name = x.Наименование_товара_рус }).ToList(); else if (Name == "IDCountries") return context.Dic_Countries.Where(x => x.Names.Contains(search)).Take(rows).Select(x => new { Id = x.Names, name = x.Names }).ToList(); else if (Name == "IDTRUType") return context.Dic_TRUType.Where(x => x.Descr.Contains(search)).Take(rows).Select(x => new { Id = x.Descr, name = x.Descr }).ToList(); return obj; } }