public static bool UpdateRawItemPrice(RawItemPriceUpdateViewModel RIPViewModel) { using (CFMMCDEntities db = new CFMMCDEntities()) { RIM_VEM_Lookup RVLRow; if (db.RIM_VEM_Lookup.Where(o => o.RIM_VEM_ID.Equals(RIPViewModel.RIM_VEM_ID)).Any()) { RVLRow = db.RIM_VEM_Lookup.Single(o => o.RIM_VEM_ID.Equals(RIPViewModel.RIM_VEM_ID)); } else { RVLRow = new RIM_VEM_Lookup(); } RVLRow.RIM_VEM_ID = RIPViewModel.RIM_VEM_ID; RVLRow.RIMRIC = int.Parse(RIPViewModel.RIMRIC); RVLRow.VEMVEN = int.Parse(RIPViewModel.VEMVEN); RVLRow.VEMDS1 = RIPViewModel.VEMDS1.Trim(); RVLRow.RIMCPR = double.Parse(RIPViewModel.RIMCPR); RVLRow.RIMRID = db.INVRIMP0.Single(o => o.RIMRIC.ToString().Equals(RIPViewModel.RIMRIC)).RIMRID; //RVLRow.RIMPDT = DateTime.Parse(RIPViewModel.RIMPDT); //RVLRow.RIMCPN = double.Parse(RIPViewModel.RIMCPN); try { if (!db.RIM_VEM_Lookup.Where(o => o.RIM_VEM_ID.Equals(RIPViewModel.RIM_VEM_ID)).Any()) { db.RIM_VEM_Lookup.Add(RVLRow); } db.SaveChanges(); return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Source); System.Diagnostics.Debug.WriteLine(e.Message); System.Diagnostics.Debug.WriteLine(e.StackTrace); System.Diagnostics.Debug.WriteLine(e.InnerException); Exception f = e.InnerException; while (f != null) { System.Diagnostics.Debug.WriteLine("INNER:"); System.Diagnostics.Debug.WriteLine(f.Message); System.Diagnostics.Debug.WriteLine(f.Source); f = f.InnerException; } System.Diagnostics.Debug.WriteLine(e.Data); return(false); } } }
public static bool DeleteRawItemPrice(RawItemPriceUpdateViewModel RIPViewModel) { using (CFMMCDEntities db = new CFMMCDEntities()) { try { if (db.RIM_VEM_Lookup.Where(o => o.RIM_VEM_ID.Equals(RIPViewModel.RIM_VEM_ID)).Any()) { RIM_VEM_Lookup rowToRemove = db.RIM_VEM_Lookup.FirstOrDefault(o => o.RIM_VEM_ID.Equals(RIPViewModel.RIM_VEM_ID)); db.RIM_VEM_Lookup.Remove(rowToRemove); db.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Source); System.Diagnostics.Debug.WriteLine(e.Message); System.Diagnostics.Debug.WriteLine(e.StackTrace); System.Diagnostics.Debug.WriteLine(e.InnerException); Exception f = e.InnerException; while (f != null) { System.Diagnostics.Debug.WriteLine("INNER:"); System.Diagnostics.Debug.WriteLine(f.Message); System.Diagnostics.Debug.WriteLine(f.Source); f = f.InnerException; } System.Diagnostics.Debug.WriteLine(e.Data); return(false); } } }
public List <INVRIMP0> GetRawItems(string Store_No, DateTime DateFrom, DateTime DateTo) { using (CFMMCDEntities db = new CFMMCDEntities()) { List <INVRIMP0> sublist = db.INVRIMP0.Where(o => o.STATUS.Equals("A")).ToList(); List <INVRIMP0> list = new List <INVRIMP0>(); List <INVRIMP0> masterlist = new List <INVRIMP0>(); list.AddRange(sublist); sublist = db.INVRIMP0.Where(o => o.STATUS.Equals("E")).ToList(); list.AddRange(sublist); sublist = list.Where(o => (o.Store != null && o.Store.Equals(Store_No))).ToList(); masterlist.AddRange(sublist); sublist = list.Where(o => (o.Store != null && o.Store.Equals("ALL"))).ToList(); masterlist.AddRange(sublist); masterlist.RemoveAll(o => (o.Except_Store != null && o.Except_Store.Equals(Store_No))); masterlist.RemoveAll(o => o.RIMDAT < DateFrom); masterlist.RemoveAll(o => o.RIMDAT > DateTo); // Prices foreach (var v in masterlist) { if (db.RIM_VEM_Lookup.Where(o => o.RIM_VEM_ID.Equals(v.RIMRIC + "" + v.RIMPVN)).Any()) { RIM_VEM_Lookup RVLRow = db.RIM_VEM_Lookup.Single(o => o.RIM_VEM_ID.Equals(v.RIMRIC + "" + v.RIMPVN)); v.RIMCPR = RVLRow.RIMCPR; v.RIMCPN = RVLRow.RIMCPN; v.RIMPDT = RVLRow.RIMPDT; } } return(masterlist); } }