public Location GetLocationByName(string name, Guid countryProgId) { using (var context = new SCMSEntities()) { return(context.Locations.FirstOrDefault(l => l.CountryProgrammeId == countryProgId && l.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); } }
private List <ShippingTerm> GetShippingTerms() { using (var db = new SCMSEntities()) { return(db.ShippingTerms.Where(s => s.CountryProgrammeId == countryProg.Id).OrderBy(s => s.Name).ToList()); } }
private void cbbLine_SelectionChangeCommitted(object sender, EventArgs e) { using (var db = new SCMSEntities()) { cMProcessBindingSource.DataSource = db.GetProcessLine(cbbLine.Text); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public Supplier GetSupplier(Guid id) { using (var dbContext = new SCMSEntities()) { return(dbContext.Suppliers.Where(c => c.Id.Equals(id)).FirstOrDefault <Supplier>()); } }
public GeneralLedger GetGeneralLedgerById(Guid id) { using (var context = new SCMSEntities()) { return(context.GeneralLedgers.Include("MasterBudgetCategory").FirstOrDefault(g => g.Id == id)); } }
private bool IsDepreciationComputed(SCMSEntities db, TransactionScope scope, Asset assetEntity) { //var firstdateinMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(-1); //var lastdateinMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(-1); //float purchasePrc = (float)gitm.PurchaseOrderItem.UnitPrice Model.Depreciation deprEntity = null; Model.GoodsReceivedNoteItem gitm = db.GoodsReceivedNoteItems.FirstOrDefault(p => p.Id == assetEntity.GoodsReceivedNoteItemId); float purchasePrc = (float)assetEntity.PurchaseValue, percentageDepr = (float)assetEntity.PercentageDepr, accAnnualDepr = 0; float annualDepr = 0, monthlyDepr, netbookValue = purchasePrc, accumulatedDepr = 0, salvagevalue = (float)assetEntity.SalvageValue; int periodcount = 0, monthcount = 0, numberOfYears = 0; if (assetEntity.DepreciationType == "Reducing Balance") { monthlyDepr = ReducingBalance(db, assetEntity, ref deprEntity, percentageDepr, ref accAnnualDepr, ref annualDepr, ref netbookValue, ref accumulatedDepr, salvagevalue, ref periodcount, ref monthcount, ref numberOfYears); } else { monthlyDepr = StraightLine(db, assetEntity, ref deprEntity, purchasePrc, percentageDepr, ref accAnnualDepr, ref annualDepr, ref netbookValue, ref accumulatedDepr, salvagevalue, ref periodcount, ref monthcount); } if (!(db.SaveChanges() > 0)) { scope.Dispose(); SessionData.CurrentSession.DepreciationList = null; return(false); } scope.Complete(); return(true); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public Country GetCountry(Guid id) { using (var dbContext = new SCMSEntities()) { return(dbContext.Countries.Where(c => c.Id.Equals(id)).FirstOrDefault <Country>()); } }
public Item GetItemByName(string name, Guid countryProgId) { using (var context = new SCMSEntities()) { return(context.Items.FirstOrDefault(i => i.CountryProgrammeId == countryProgId && i.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); } }
/// <summary> /// /// </summary> /// <param name="search"></param> /// <returns></returns> public List <ItemView> GetItems1(Guid cpid, string search = null) { using (var dbContext = new SCMSEntities()) { var itemList = from item in dbContext.Items where item.CountryProgrammeId == cpid select item; if (!string.IsNullOrEmpty(search)) { itemList = from item in itemList where item.Name.Contains(search) select item; } return((from item in itemList select new ItemView { itemCategory = item.ItemCategory, itemClassification = item.ItemClassification, item = item } ).ToList()); } }
public List <ItemPackage> GetItemPackages(Guid itemId) { using (var db = new SCMSEntities()) { return(db.ItemPackages.Where(p => p.ItemId == itemId).ToList()); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public Item GetItem(Guid id) { using (var dbContext = new SCMSEntities()) { return(dbContext.Items.Where(c => c.Id.Equals(id)).FirstOrDefault <Item>()); } }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public bool AddItem(Item item) { bool isSaved = false; if (item.Id.Equals(Guid.Empty)) { item.Id = Guid.NewGuid(); } using (var context = new SCMSEntities()) { UnitOfMeasure u = context.UnitOfMeasures.FirstOrDefault(p => p.Id == item.UnitOfMessureId); context.Items.Add(item); context.ItemPackages.Add(new ItemPackage() { Id = Guid.NewGuid(), ItemId = item.Id, PackSize = 1, shortName = u.Code, Name = u.Description }); if (context.SaveChanges() > 0) { isSaved = true; ClearItemSessionData(); } } return(isSaved); }
/// <summary> /// /// </summary> /// <param name="search"></param> /// <param name="countryId"></param> /// <returns></returns> public List <Location> GetLocations(string search = null, Guid?countryId = null) { //List<Location> locationList = new List<Location>(); using (var dbContext = new SCMSEntities()) { var locationList = from location in dbContext.Locations select location; if (!string.IsNullOrEmpty(search)) { locationList = from location in locationList where location.Name.Contains(search) || location.ShortName.Contains(search) orderby location.Name select location; } if (countryId != null) { locationList = from location in locationList join country in dbContext.Countries on location.CountryId equals country.Id where location.CountryId == countryId orderby location.Name select location; } return(locationList.ToList <Location>()); } }
public List <Location> GetLocations(Guid countryProgId) { using (var context = new SCMSEntities()) { return(context.Locations.Where(l => l.CountryProgrammeId == countryProgId).OrderBy(l => l.Name).ToList()); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public Currency GetCurrency(Guid id) { using (var dbContext = new SCMSEntities()) { return(SessionData.CurrentSession.CurrencyList.FirstOrDefault(c => c.Id.Equals(id))); } }
public ActionResult DocsDashBoard() { using (var dbContext = new SCMSEntities()) { DocsDashBoard model = new DocsDashBoard(); model.OrCreated = dbContext.OrderRequests.Count(p => p.CountryProgrammeId == countryProg.Id); model.OrApproved = dbContext.OrderRequests.Count(p => p.IsReviewed == true && p.IsAuthorized == false && p.CountryProgrammeId == countryProg.Id); model.OrOngoing = dbContext.OrderRequests.Count(p => p.IsAuthorized == true && p.CountryProgrammeId == countryProg.Id); if (dbContext.OrderRequests.Count(p => p.CountryProgrammeId == countryProg.Id) > 0) { model.OrTotalValue = (decimal)dbContext.OrderRequests.Where(q => q.IsAuthorized == true && q.CountryProgrammeId == countryProg.Id).Sum(p => p.TotalAmount); } model.TaTotalValue = 0; model.PoCreated = dbContext.PurchaseOrders.Count(p => p.CountryProgrammeId == countryProg.Id); model.PoApproved = dbContext.PurchaseOrders.Count(p => p.IsApproved && p.CountryProgrammeId == countryProg.Id); model.PoOngoing = dbContext.PurchaseOrders.Count(p => p.IsApproved && p.CountryProgrammeId == countryProg.Id); if (dbContext.PurchaseOrders.Count(p => p.CountryProgrammeId == countryProg.Id && p.IsApproved == true) > 0) { model.PoTotalValue = (decimal)dbContext.PurchaseOrders.Where(q => q.IsApproved == true && q.CountryProgrammeId == countryProg.Id).Sum(p => p.TotalAmount); } return(View(model)); } }
public void AssignRoles(SystemUser user, params Guid[] roleIds) { roleIds = roleIds ?? Enumerable.Empty <Guid>().ToArray(); var userRoles = GetUserRoles(user.Id, false); using (var context = SCMSEntities.Define()) { var toDelete = userRoles.Where(p => !roleIds.Contains(p.RoleId)).ToArray(); var roleIdsToAdd = roleIds.Select(p => p).Delete <Guid>(userRoles.Select(p => p.RoleId)); toDelete.ForEach(DeleteUserRole); roleIdsToAdd.ForEach(p => context.SystemUserRoles .Add(new SystemUserRole { Id = Guid.NewGuid(), Created = DateTime.Now, Modified = DateTime.Now, RoleId = p, SystemUserId = user.Id, })); context.SaveChanges(); } }
public bool SavePuchaseOrder(Model.PurchaseOrder entity) { using (var context = new SCMSEntities()) { if (entity.Id.Equals(Guid.Empty)) { entity.Id = Guid.NewGuid(); context.PurchaseOrders.Add(entity); } else { var po = context.PurchaseOrders.FirstOrDefault(p => p.Id == entity.Id); po.CurrencyId = entity.CurrencyId; po.DeliveryAddress = entity.DeliveryAddress; po.LatestDeliveryDate = entity.LatestDeliveryDate; po.PaymentTermId = entity.PaymentTermId; po.PODate = entity.PODate; po.ProjectDonorId = entity.ProjectDonorId; po.QuotationRef = entity.QuotationRef; po.Remarks = entity.Remarks; po.ShippingTermId = entity.ShippingTermId; po.SupplierId = entity.SupplierId; po.IsInternational = entity.IsInternational; } ClearPOSessionData(); return(context.SaveChanges() > 0); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public Designation GetDesignation(Guid id) { using (var dbContext = new SCMSEntities()) { return(dbContext.Designations.Where(c => c.Id.Equals(id)).FirstOrDefault <Designation>()); } }
public void DeletePO(Guid PoId) { using (var context = new SCMSEntities()) { using (TransactionScope scope = new TransactionScope()) { try { var po = context.PurchaseOrders.FirstOrDefault(p => p.Id == PoId); po.PurchaseOrderItems.ToArray().ForEach(p => context.PurchaseOrderItems.Remove(p)); context.PurchaseOrders.Remove(po); context.AttachedDocuments.Where(d => d.DocumentId == po.Id && d.DocumentType == NotificationHelper.poCode).ToArray().ForEach(d => context.AttachedDocuments.Remove(d)); if (context.SaveChanges() > 0) { scope.Complete(); } else { scope.Dispose(); } } catch (Exception ex) { scope.Dispose(); throw ex; } ClearPOSessionData(); ClearORSessionData(); } } }
public Supplier GetSupplierByName(string name, Guid countryProgId) { using (var context = new SCMSEntities()) { return(context.Suppliers.FirstOrDefault(s => s.CountryProgrammeId == countryProgId && s.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); } }
public IQueryable <T> GetDocAttachments <T>(Expression <Func <T, bool> > expression) where T : EntityObject { using (var context = new SCMSEntities()) { return(((IObjectContextAdapter)context).ObjectContext.CreateObjectSet <T>().Where(expression)); } }
/// <summary> /// /// </summary> /// <param name="search"></param> /// <returns></returns> public List <SupplierServiceView> GetSuppliers1(Guid cpId, string search = null) { List <SupplierServiceView> locationList = new List <SupplierServiceView>(); using (var dbContext = new SCMSEntities()) { if (string.IsNullOrEmpty(search)) { locationList = (from supplier in dbContext.Suppliers join country in dbContext.Countries on supplier.CountryId equals country.Id where supplier.CountryProgrammeId == cpId select new SupplierServiceView { Supplier = supplier, Country = country.Name }).OrderBy(s => s.Supplier.Name).ToList(); } else { locationList = (from supplier in dbContext.Suppliers join country in dbContext.Countries on supplier.CountryId equals country.Id where supplier.Name.Contains(search) && supplier.CountryProgrammeId == cpId select new SupplierServiceView { Supplier = supplier, Country = country.Name }).OrderBy(s => s.Supplier.Name).ToList(); } } return(locationList); }
public T GetEntityById <T>(object id) where T : EntityObject { using (var context = new SCMSEntities()) { return(((IObjectContextAdapter)context).ObjectContext.CreateObjectSet <T>().FirstOrDefault(t => t.EntityKey.EntityKeyValues[0].Value == id)); } }
public ActionResult ListView() { using (var db = new SCMSEntities()) { return(View("ListView", GetShippingTerms())); } }
public List <Model.AttachedDocument> GetList(Guid DocId, Guid cpId) { using (var db = new SCMSEntities()) { return(db.AttachedDocuments.Where(p => p.DocumentId == DocId && p.CountryProgrammeId == cpId).ToList()); } }
// // GET: /ShippingTerm/Edit/5 public ActionResult Edit(Guid id) { using (var db = new SCMSEntities()) { return(View("CreateEdit", db.ShippingTerms.SingleOrDefault(p => p.Id == id))); } }
public void BackDatePO(Model.PurchaseOrder po) { using (var context = new SCMSEntities()) { using (TransactionScope scope = new TransactionScope()) { try { //Get Current OR from DB var currentPO = context.PurchaseOrders.FirstOrDefault(o => o.Id == po.Id); //Initialize BackDate object var backDate = new DocumentBackDating(); backDate.Id = Guid.NewGuid(); backDate.BackDatedBy = po.BackDatedBy; backDate.BackDatedOn = DateTime.Now; backDate.NewDate = po.PODate; backDate.PurchaseOrderId = po.Id; backDate.PreviousDate = currentPO.PODate; backDate.Reason = po.BackDatingReason; //Insert BackDate details into db context.DocumentBackDatings.Add(backDate); //Update date on OR in db currentPO.PODate = po.PODate; context.SaveChanges(); scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw ex; } } } }
private void cbbZone_SelectionChangeCommitted(object sender, EventArgs e) { using (var db = new SCMSEntities()) { cMLineBindingSource.DataSource = db.Proc_Find_LineZone(cbbZone.Text); } }
public List <GeneralInventorySummary> Find(List <Guid> ids) { List <GeneralInventorySummary> invs = new List <GeneralInventorySummary>(); using (var context = new SCMSEntities()) { var results = from myInventory in SessionData.CurrentSession.InventoryList where ids.Contains(myInventory.Id) select myInventory; foreach (Model.Inventory item in results.ToList()) { GeneralInventorySummary tmp = new GeneralInventorySummary(); tmp.Id = item.Id; tmp.Classification = item.Item.ItemClassification.Name; tmp.ItemName = item.Item.Name; tmp.Category = item.Item.ItemCategory.CategoryName; tmp.Quantity = item.Quantity; invs.Add(tmp); } } return(invs); }