public List<Tuple<string, string, string, double>> GetItem() { List<Tuple<string, string, string, double>> lst = new List<Tuple<string, string, string, double>>(); Tuple<string, string, string, double> myTuple; using (inventoryEntities contxt=new inventoryEntities()) try { var item = from a in contxt.item_desc join b in contxt.item_type on a.type_id equals b.type_id orderby b.type_desc, a.brand, a.item_desc1 select new { item_name = a.item_desc1, item_brand = a.brand, item_type = b.type_desc, item_price = (double)a.price }; foreach (var i in item) { myTuple = Tuple.Create(i.item_name, i.item_brand , i.item_type, i.item_price); lst.Add(myTuple); } } catch (Exception ex) { throw ex; } return lst; }
public Dictionary<int, string> GetItemDesc(int _itemType =-1) { Dictionary<int, string> _lst = new Dictionary<int, string>(); using (inventoryEntities context = new inventoryEntities()) try { var query = from a in context.item_desc orderby a.brand,a.item_desc1 select new { a.brand, a.item_desc1, a.item_desc_id }; if (_itemType != -1) { query = from a in context.item_desc where a.type_id==_itemType orderby a.brand,a.item_desc1 select new { a.brand, a.item_desc1, a.item_desc_id }; } foreach (var aa in query) { _lst.Add(aa.item_desc_id, string.Concat(aa.brand,"-", aa.item_desc1)); } } catch (Exception ex) { throw ex; } return _lst; }
public void NewItem(string iName, int qlty, int descId, DateTime dt) { using (inventoryEntities ctxt=new inventoryEntities()) try { item ItemAdd=new item(); ItemAdd.name=iName.Trim(); ItemAdd.quality=qlty; ItemAdd.item_desc_id=descId; ItemAdd.inDate = new DateTime(dt.Year, dt.Month, dt.Day); ctxt.item.Add(ItemAdd); ctxt.SaveChanges(); } catch (Exception ex) { throw ex; } }
public string GetTest() { string rslt; using (inventoryEntities context =new inventoryEntities()) try{ var query=from a in context.item select a.name ; rslt= query.ToList().First(); } catch (Exception ex) { throw ex; } return rslt; }
public List<Tuple<int, DateTime, string, string, int, Single, Single>> GetRpt() { List<Tuple<int, DateTime, string, string, int, Single, Single>> lst = new List<Tuple<int, DateTime, string, string, int, Single, Single>>(); Tuple<int, DateTime, string, string, int, Single, Single> myTuple; using (inventoryEntities context = new inventoryEntities()) try{ var query = from a in context.item join b in context.item_desc on a.item_desc_id equals b.item_desc_id join c in context.item_type on b.type_id equals c.type_id orderby a.item_id select new { item_id =a.item_id, in_date=(DateTime)a.inDate, type_desc =c.type_desc, item_desc =string.Concat(b.brand ," ",b.item_desc1 ), quality =a.quality, unit_price = (Single) b.price, total_price =(Single)(a.quality *b.price ) }; foreach (var iq in query) { myTuple = Tuple.Create(iq.item_id, iq.in_date, iq.type_desc, iq.item_desc, iq.quality, iq.unit_price, iq.total_price); lst.Add(myTuple); } } catch (Exception ex) { throw ex; } return lst; }
public Dictionary<int, string> GetItemType() { Dictionary<int, string> _lst = new Dictionary<int, string>(); using (inventoryEntities context = new inventoryEntities()) try { var query = from a in context.item_type orderby a.type_desc select new{ a.type_id, a.type_desc }; foreach (var aa in query) { _lst.Add(aa.type_id, aa.type_desc); } } catch (Exception ex) { throw ex; } return _lst; }