private void Save() { if (isNew) { contxt.PriceLists.Add(priceList); contxt.Entry(priceList).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); contxt.Entry(priceList).Reload(); } if (isEdit) { PriceList ptmp = contxt.PriceLists.FirstOrDefault(o => o.id == priceList.id); if (ptmp != null) { ptmp.ModifiedBy = 1; ptmp.ModifiedDate = DateTime.Now; ptmp.PartnerId = priceList.PartnerId; ptmp.ProductId = priceList.ProductId; ptmp.Status = priceList.Status; ptmp.PriceListType = priceList.PriceListType; ptmp.EffectFrom = priceList.EffectFrom; ptmp.EffectTo = priceList.EffectTo; contxt.Entry(ptmp).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); contxt.Entry(priceList).Reload(); } } //throw new NotImplementedException(); }
private void Save() { if (isNew) { ledger.CreatedBy = 1; ledger.CreatedDate = DateTime.Now; contxt.SupplierLedgers.Add(ledger); contxt.Entry(ledger).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); contxt.Entry(ledger).Reload(); sessionList.Add(ledger); } if (isEdit) { SupplierLedger led = contxt.SupplierLedgers.FirstOrDefault(o => o.id == ledger.id); if (led != null) { led.ModifiedBy = 1; led.ModifiedDate = DateTime.Now; led.ProductId = ledger.ProductId; led.Quantity = ledger.Quantity; led.Ref01 = ledger.Ref01; led.Ref02 = ledger.Ref02; led.SupplierId = ledger.SupplierId; led.TotalPrice = ledger.TotalPrice; led.TrnDate = ledger.TrnDate; led.UnitPrice = ledger.UnitPrice; contxt.Entry(led).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); contxt.Entry(ledger).Reload(); } } ShowSession(); }
private void Save() { if (isNew) { product.CreatedBy = 1; product.CreatedDate = DateTime.Now; contxt.Products.Add(product); contxt.Entry(product).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); } if (isEdit) { Product ptemp = contxt.Products.Where(o => o.id == product.id).FirstOrDefault(); if (ptemp != null) { ptemp.Conversion = product.Conversion; ptemp.FactoryId = product.FactoryId; ptemp.ModifiedBy = 1; ptemp.ModifiedDate = DateTime.Now; ptemp.PrintOrder = product.PrintOrder; ptemp.ProductName = product.ProductName; ptemp.TransactionType = product.TransactionType; ptemp.UOM1 = product.UOM1; ptemp.UOM2 = product.UOM2; contxt.Entry(ptemp).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); } } }
private void OpenClosePeriod() { period = contxt.FiscalPeriods.FirstOrDefault(o => o.FromDate.Value.Month == dtM.Value.Month && o.FromDate.Value.Year == dtM.Value.Year); if (period == null) { period = new FiscalPeriod(); period.FromDate = new DateTime(dtM.Value.Year, dtM.Value.Month, 1); period.Todate = period.FromDate.Value.AddMonths(1).AddDays(period.FromDate.Value.Day * -1); period.Status = chkClose.Checked ? 1 : 0;; contxt.FiscalPeriods.Add(period); contxt.Entry(period).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); } else { period.Status = chkClose.Checked ? 1 : 0; contxt.Entry(period).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); } }
private void Save() { if (isNew) { contxt.FiscalPeriods.Add(period); contxt.Entry(period).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); contxt.Entry(period).Reload(); } if (isEdit) { FiscalPeriod ptemp = contxt.FiscalPeriods.FirstOrDefault(o => o.id == period.id); if (ptemp != null) { ptemp.FromDate = period.FromDate; ptemp.Todate = period.Todate; ptemp.Status = period.Status; contxt.Entry(ptemp).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); contxt.Entry(period).Reload(); } } //throw new NotImplementedException(); }
private void Save() { if (isNew) { address.CreatedBy = 1; address.CreatedDate = DateTime.Now; contxt.AddressBooks.Add(address); contxt.Entry(address).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); isNew = false; isEdit = false; state = FORMSTATE.NOOP; SetButtons(); } if (isEdit) { AddressBook book = contxt.AddressBooks.Where( o => o.id == address.id).FirstOrDefault(); if (book != null) { book.ModifiedBy = 1; book.ModifiedDate = DateTime.Now; book.AddressName = address.AddressName; book.AddressLine01 = address.AddressLine01; book.AddressLine02 = address.AddressLine02; book.AddressBookType = address.AddressBookType; contxt.SaveChanges(); isNew = false; isEdit = false; state = FORMSTATE.NOOP; SetButtons(); } } }
private void Save() { if (isNew) { contxt.RouteMasters.Add(route); contxt.Entry(route).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); contxt.Entry(route).Reload(); } if (isEdit) { RouteMaster r = contxt.RouteMasters.FirstOrDefault(o => o.ind == route.ind); if (r != null) { r.rName = route.rName; r.rCode = route.rCode == "" ? "NNN" : route.rCode; r.trActive = route.trActive; r.DdRate = route.DdRate; contxt.Entry(r).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); contxt.Entry(route).Reload(); } } }
private void Save() { if (isNew) { address.CreatedBy = 1; address.CreatedDate = DateTime.Now; contxt.AddressBooks.Add(address); contxt.Entry(address).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); contxt.Entry(address).Reload(); supplier.CreatedDate = DateTime.Now; supplier.CreatedBy = 1; supplier.AddressBookId = address.id; contxt.SupplierMasters.Add(supplier); contxt.Entry(supplier).State = System.Data.Entity.EntityState.Added; contxt.SaveChanges(); } if (isEdit) { // Update mechanism should be coded AddressBook book = contxt.AddressBooks.Where(o => o.id == address.id).FirstOrDefault(); if (book != null) { book.AddressLine01 = address.AddressLine01; book.AddressLine02 = address.AddressLine02; book.AddressName = address.AddressName; book.AddressType = address.AddressType; book.City = address.City; book.ModifiedBy = 1; book.ModifiedDate = DateTime.Now; contxt.Entry(book).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); SupplierMaster master = contxt.SupplierMasters.Where(o => o.id == supplier.id).FirstOrDefault(); if (master != null) { master.AddressBookId = address.id; master.ModifiedBy = 1; master.ModifiedDate = DateTime.Now; master.RegNo = supplier.RegNo; master.SavingRegDate = supplier.SavingRegDate; master.SavingRegistered = supplier.SavingRegistered; master.WelfareId = supplier.WelfareId; master.WelfareRegDate = supplier.WelfareRegDate; master.WelfareRegistered = supplier.WelfareRegistered; master.Status = supplier.Status; contxt.Entry(master).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); } } } }