public IQueryable <Data.Part> Search(PartSearchModel partSearchModel) { IQueryable <Part> Part = this.context.Part; if (!string.IsNullOrEmpty(partSearchModel.PartNr)) { Part = Part.Where(c => c.PartNr.Equals(partSearchModel.PartNr)); } return(Part); }
static void Main(string[] args) { PartSearchModel p = new PartSearchModel(); IPartServices q = new PartServices("Data Source = (local); Initial Catalog = AgvWarehouseDB; Integrated Security = True"); // IPartServices q = new PartServices("Data Source = 42.121.111.38; Initial Catalog = BlueCarGps; Persist Security Info = True; User ID = bluecargps; Password = bluecargps; Connect Timeout = 150;"); Part a = q.SearchByNr("PN001"); Console.WriteLine(a.BoxType); Console.ReadLine(); }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); PartSearchModel q = new PartSearchModel(); IPartService ps = new PartService(Settings.Default.db); IPagedList <Part> parts = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; SetPartTypeList(null); return(View(parts)); }
public ActionResult Search([Bind(Include = "PartNr, PartType")] PartSearchModel q) { int pageIndex = 0; int.TryParse(Request.QueryString.Get("page"), out pageIndex); pageIndex = PagingHelper.GetPageIndex(pageIndex); IPartService ps = new PartService(Settings.Default.db); IPagedList <Part> parts = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; SetPartTypeList(q.PartType); return(View("Index", parts)); }
public void Export([Bind(Include = "PartNr, PartType")] PartSearchModel q) { IPartService ps = new PartService(Settings.Default.db); List <Part> parts = ps.Search(q).ToList(); ViewBag.Query = q; MemoryStream ms = new MemoryStream(); using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8)) { List <string> head = new List <string> { " No.", "PartNr", "PartType", "PartDesc", "PartStatus", "MOQ", "SPQ", "Action" }; sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head)); for (var i = 0; i < parts.Count; i++) { List <string> ii = new List <string>(); ii.Add((i + 1).ToString()); ii.Add(parts[i].partNr); ii.Add(parts[i].partType.ToString()); ii.Add(parts[i].partDesc); ii.Add(parts[i].partStatus.ToString()); ii.Add(parts[i].moq.ToString()); ii.Add(parts[i].spq.ToString()); ii.Add(""); sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray())); } //sw.WriteLine(max); } var filename = "Parts" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; var contenttype = "text/csv"; Response.Clear(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = contenttype; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(ms.ToArray()); Response.End(); }
public IQueryable <Data.Part> Search(PartSearchModel partSearchModel) { return(PartRep.Search(partSearchModel)); }