// Creating a single PO entry public static bool CreateSinglePO(ReorderRecord r) { using (SA45Team12AD context = new SA45Team12AD()) { try { SupplierList s = context.SupplierLists.Where(x => x.SupplierID.Equals(r.SupplierID)).First(); PORecord p = new PORecord(); p.DateRequested = DateTime.Now; p.RecipientName = "System-generated"; p.DeliveryAddress = "21 Lower Kent Ridge Rd, Singapore 119077"; // Default address p.SupplierID = r.SupplierID; p.CreatedBy = "Logic University Stationery Store"; p.ExpectedDelivery = DateTime.Now.AddDays(Convert.ToDouble(s.OrderLeadTime)); p.Status = "Pending"; context.PORecords.Add(p); context.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
// Creating a single PODetails entry public static bool CreateSinglePODetails(ReorderRecord r) { using (SA45Team12AD context = new SA45Team12AD()) { try { // Finding the newly created PO record PORecord pr = context.PORecords.OrderByDescending(x => x.PONumber).First(); // Req to populate the values for the new entry InventoryCatalogue iv = context.InventoryCatalogues.Where(x => x.ItemID.Equals(r.ItemID)).First(); // To retrieve UOM SupplierCatalogue sc = context.SupplierCatalogues.Where(x => x.ItemID.Equals(r.ItemID)).Where(y => y.SupplierID.Equals(r.SupplierID)).First(); // TO retrieve price // Creating our new entry... PORecordDetail pd = new PORecordDetail(); pd.PONumber = pr.PONumber; pd.ItemID = r.ItemID; pd.Quantity = r.OrderedQuantity; pd.UOM = iv.UOM; pd.UnitPrice = sc.Price; context.PORecordDetails.Add(pd); context.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public static bool UpdateDisbursementStatus(int disbursementId, string status) { string email; string collectPoint; string dateTime; bool success = false; using (SA45Team12AD ctx = new SA45Team12AD()) { DisbursementList dL = ctx.DisbursementLists.Where(x => x.DisbursementID == disbursementId).FirstOrDefault(); email = Utility.Utility.GetEmailAddressByName(dL.RepresentativeName); collectPoint = GetCurrentCPWithTimeByID(dL.CollectionPointID); dateTime = ((DateTime)dL.CollectionDate).ToString("d"); dL.Status = status; ctx.SaveChanges(); success = true; } if (status == "Cancelled") { using (EmailControl em = new EmailControl()) { em.CancelStationeryCollectionNotification(email, collectPoint, dateTime); } } return(success); }
// Create multiple PO from a list of reorder records public static string CreateMultiplePO(List <ReorderRecord> tempList) { using (SA45Team12AD context = new SA45Team12AD()) { try { foreach (var item in tempList) { bool res1 = CreateSinglePO(item); bool res2 = CreateSinglePODetails(item); if (!res1 || !res2) { throw new Exception(); } // Gotta clear all the reorder records that are in the db according to their itemid List <ReorderRecord> rList = context.ReorderRecords.Where(x => x.ItemID.Equals(item.ItemID)).ToList(); foreach (var item1 in rList) { context.ReorderRecords.Remove(item1); } context.SaveChanges(); } // Finall~ return("All purchase orders were successfully created and has been send to the supervisor for approval."); } catch (Exception) { return("Failure to create all purchase orders."); } } }
//------------ Lim Chang Siang's Code Ends Here-------------------------------// //------ Li Jianing'S Code start Here------------------------------// public static int AddText(string Deliverto, string Address, string SupplierID, DateTime RequestedDate, string userName, DateTime ExpectedBy) { //Put here so other methods can use even after the EF object is disposed. PORecord poRecord; using (SA45Team12AD entities = new SA45Team12AD()) { poRecord = new PORecord(); poRecord.RecipientName = Deliverto; poRecord.DeliveryAddress = Address; poRecord.SupplierID = SupplierID; poRecord.Status = "Pending"; poRecord.DateRequested = RequestedDate; poRecord.CreatedBy = userName; poRecord.ExpectedDelivery = ExpectedBy; entities.PORecords.Add(poRecord); entities.SaveChanges(); } //Using System.Web.Security feature. List <MembershipUser> userList = Utility.Utility.GetListOfMembershipUsers(); string[] approveAuthList = Roles.GetUsersInRole("Supervisor"); string clerkName = HttpContext.Current.Profile.GetPropertyValue("fullname").ToString(); foreach (string s in approveAuthList) { var User = userList.Find(x => x.UserName == s); using (EmailControl em = new EmailControl()) { em.NewPurchaseOrderForApprovalNotification(User.Email.ToString(), clerkName, poRecord.PONumber.ToString(), DateTime.Now.Date.ToString("d")); } } //Return the new PONumber. return(poRecord.PONumber); }
//----------------------------- Pradeep Elango's Code Starts Here--------------------// public static void AddDelegate(String fullname, DateTime startdate, DateTime enddate, string depid) { if (startdate >= DateTime.Today && enddate >= startdate) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail delegateDetail = new DDelegateDetail { DepartmentID = depid, DepartmentHeadDelegate = fullname, StartDate = startdate, EndDate = enddate }; entities.DDelegateDetails.Add(delegateDetail); Department department = entities.Departments.Where(x => x.DeptID == depid).First(); department.HasDelegate = 1; entities.SaveChanges(); } if (startdate == DateTime.Today) { AddDeptHeadRoleToUser(fullname, depid); } } }
//--------------- THET NAING AYE Ends Here-----------------------// //------------- Yuan Yishu's Code Starts Here----------------------// public static void DeleteSupplier(string SupplierID) { using (SA45Team12AD entities = new SA45Team12AD()) { SupplierList supplier = entities.SupplierLists.Where(s => s.SupplierID == SupplierID).First <SupplierList>(); entities.SupplierLists.Remove(supplier); entities.SaveChanges(); } }
public static void UpdateOrderLeadTime(int orderLeadTime, string supplierID) { using (SA45Team12AD entities = new SA45Team12AD()) { SupplierList supplier = entities.SupplierLists.Where(p => p.SupplierID == supplierID).First <SupplierList>(); supplier.OrderLeadTime = orderLeadTime; entities.SaveChanges(); } }
public static void UpdateBufferStockLevel(string itemid, int newbufferstocklevel) { using (SA45Team12AD entities = new SA45Team12AD()) { InventoryCatalogue inventory = entities.InventoryCatalogues.Where(x => x.ItemID == itemid).Single(); inventory.BufferStockLevel = newbufferstocklevel; inventory.BFSProportion = 0; entities.SaveChanges(); } }
public static bool CancelPORecordRequest(int poNo) { bool success = false; using (SA45Team12AD entities = new SA45Team12AD()) { PORecord poRecord = entities.PORecords.FirstOrDefault(x => x.PONumber == poNo); poRecord.Status = "Cancelled"; entities.SaveChanges(); success = true; } return(success); }
public static void AddItem(string ItemID, int Quantity, string UOM, double UnitPrice) { using (SA45Team12AD entities = new SA45Team12AD()) { PORecordDetail poRecordDetails = new PORecordDetail(); poRecordDetails.ItemID = ItemID; poRecordDetails.Quantity = Quantity; poRecordDetails.UOM = UOM; poRecordDetails.UnitPrice = UnitPrice; entities.PORecordDetails.Add(poRecordDetails); entities.SaveChanges(); } }
public static bool Submitforapproval(int poNo) { bool success = true; using (SA45Team12AD entities = new SA45Team12AD()) { PORecord poRecord = entities.PORecords.FirstOrDefault(x => x.PONumber == poNo); entities.SaveChanges(); success = true; } return(success); }
// Removing selected entries from the Reorder table public static void RemoveReorderRecord(string itemID, string suppID) { using (SA45Team12AD context = new SA45Team12AD()) { List <ReorderRecord> r = context.ReorderRecords.Where(x => x.ItemID.Equals(itemID)).Where(y => y.SupplierID.Equals(suppID)).ToList(); // Remove everything retrieved in the list foreach (var item in r) { context.ReorderRecords.Remove(item); } context.SaveChanges(); } }
//----------------- Li Jianing's Code Ends Here------------------// //-------------------- Lim Chang Siang and Yuan Yishu's Code Starts Here-----------------------// public static int CreateRequisitionRecord(string requestorName, string departmentId, DateTime requestDate) { using (SA45Team12AD ctx = new SA45Team12AD()) { RequisitionRecord r = new RequisitionRecord(); r.RequestorName = requestorName; r.DepartmentID = departmentId; r.RequestDate = requestDate; ctx.RequisitionRecords.Add(r); ctx.SaveChanges(); return(r.RequestID); } }
public void CreateStationeryRequestDetails(int requestId, string itemId, int requestedQuantity) { RequisitionRecordDetail rRDetails = new RequisitionRecordDetail(); rRDetails.RequestID = requestId; rRDetails.ItemID = itemId; rRDetails.RequestedQuantity = requestedQuantity; rRDetails.Status = "Approved"; rRDetails.Priority = "Yes"; using (SA45Team12AD ctx = new SA45Team12AD()) { ctx.RequisitionRecordDetails.Add(rRDetails); ctx.SaveChanges(); } }
public bool UpdateDisbursementListDetails(int id, int quantityCollected, string remarks) { bool success = false; using (SA45Team12AD ctx = new SA45Team12AD()) { DisbursementListDetail dListDetails = ctx.DisbursementListDetails.Where(x => x.ID == id).FirstOrDefault(); CheckForOutstandingItem(quantityCollected, dListDetails, remarks); dListDetails.QuantityCollected = quantityCollected; dListDetails.Remarks = remarks; ctx.SaveChanges(); success = true; } return(success); }
public static RequisitionRecordDetail CreateRequisitionRecordDetail(int requestId, string itemCode, int quantity, string status, string priority) { using (SA45Team12AD ctx = new SA45Team12AD()) { RequisitionRecordDetail r = new RequisitionRecordDetail(); r.RequestID = requestId; r.ItemID = itemCode; r.RequestedQuantity = quantity; r.Status = status; r.Priority = priority; ctx.RequisitionRecordDetails.Add(r); ctx.SaveChanges(); return(r); } }
//Method for Posting GR public int CreateGoodsReceipt(DateTime dateProcessed, int poNumber, string receivedBy, string doNumber) { using (SA45Team12AD ctx = new SA45Team12AD()) { GoodReceipt goodReceipt = new GoodReceipt { PONumber = poNumber, ReceivedBy = receivedBy, DateProcessed = dateProcessed, DONumber = doNumber }; ctx.GoodReceipts.Add(goodReceipt); ctx.SaveChanges(); return(goodReceipt.GRNumber); } }
public static void UpdateSupplier(string SupplierID, string SupplierName, string GSTRegistrationNo, string ContactName, int PhoneNo, int FaxNo, string Address, int OrderLeadTime, string Discontinued) { using (SA45Team12AD entities = new SA45Team12AD()) { SupplierList supplier = entities.SupplierLists.Where(s => s.SupplierID == SupplierID).First <SupplierList>(); supplier.SupplierName = SupplierName; supplier.GSTRegistrationNo = GSTRegistrationNo; supplier.ContactName = ContactName; supplier.PhoneNo = PhoneNo; supplier.FaxNo = FaxNo; supplier.Address = Address; supplier.OrderLeadTime = OrderLeadTime; supplier.Discontinued = Discontinued; entities.SaveChanges(); } }
public void CreateGoodsReceiptDetails(int grNumber, string itemID, int quantity, string uom, string remarks) { GoodReceiptDetail grd = new GoodReceiptDetail(); grd.GRNumber = grNumber; grd.ItemID = itemID; grd.Quantity = quantity; grd.UOM = uom; grd.Remarks = remarks; using (SA45Team12AD ctx = new SA45Team12AD()) { ctx.GoodReceiptDetails.Add(grd); ctx.SaveChanges(); } InventoryLogic.LessUnitsOnOrder(itemID, quantity); }
public void CreateDisbursementListDetails(int disbursementId, string itemId, int actualQuantity, int quantityRequested, int quantityCollected, string uom, string remarks) { DisbursementListDetail dListDetails = new DisbursementListDetail(); dListDetails.DisbursementID = disbursementId; dListDetails.ItemID = itemId; dListDetails.ActualQuantity = actualQuantity; dListDetails.QuantityRequested = quantityRequested; dListDetails.QuantityCollected = quantityCollected; dListDetails.UOM = uom; dListDetails.Remarks = remarks; using (SA45Team12AD ctx = new SA45Team12AD()) { ctx.DisbursementListDetails.Add(dListDetails); ctx.SaveChanges(); } }
public int CreateSystemStationeryRequest(DateTime requestDate, string deptId, string remarks) { RequisitionRecord rRecord = new RequisitionRecord(); using (SA45Team12AD ctx = new SA45Team12AD()) { rRecord.DepartmentID = deptId; rRecord.Remarks = remarks; rRecord.RequestorName = "DisbursementLogic"; rRecord.RequestDate = DateTime.Now.Date; rRecord.ApprovedDate = DateTime.Now.Date; rRecord.ApproverName = "System Generated Request"; ctx.RequisitionRecords.Add(rRecord); ctx.SaveChanges(); return(rRecord.RequestID); } }
public void CreatePurchaseOrderDetails(int poNumber, string itemId, int quantity, string uom, double unitPrice) { using (SA45Team12AD entities = new SA45Team12AD()) { PORecordDetail poRecordDetail = new PORecordDetail { PONumber = poNumber, ItemID = itemId, Quantity = quantity, UOM = uom, UnitPrice = unitPrice, }; entities.PORecordDetails.Add(poRecordDetail); entities.SaveChanges(); } }
public static void UpdateDelegate(DDelegateDetail dDelegateinput, DateTime newstartdate, DateTime newenddate) { //if (Roles.IsUserInRole(DisbursementLogic.GetUserName(dDelegateinput.DepartmentHeadDelegate, dDelegateinput.DepartmentID), "HOD")) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail dDelegate = entities.DDelegateDetails.Where(p => p.DepartmentHeadDelegate == dDelegateinput.DepartmentHeadDelegate).Where(x => x.DepartmentID == dDelegateinput.DepartmentID).Where(x => x.StartDate == dDelegateinput.StartDate).Where(x => x.EndDate == dDelegateinput.EndDate).First(); dDelegate.StartDate = newstartdate; dDelegate.EndDate = newenddate; entities.SaveChanges(); } using (EmailControl em = new EmailControl()) { List <string> depuseremails = new List <string>(); depuseremails = Utility.Utility.GetAllUserEmailAddressListForDept(dDelegateinput.DepartmentID); } } }
private bool IsPOCompleted(int itemCount, int poNumber) { bool isCompleted = false; if (itemCount == 0) { using (SA45Team12AD ctx = new SA45Team12AD()) { PORecord poR = ctx.PORecords.Where(x => x.PONumber == poNumber).FirstOrDefault(); poR.Status = "Completed"; ctx.SaveChanges(); isCompleted = true; return(isCompleted); } } return(isCompleted); }
protected void RemoveDeptHeadRoleFromUserWithDateCheck(object sender, System.Timers.ElapsedEventArgs e) { List <Department> depwithdelegateslist = new List <Department>(); List <Department> deplist = new List <Department>(); List <DDelegateDetail> delegatelist = new List <DDelegateDetail>(); List <DateTime> startdates = new List <DateTime>(); List <DateTime> enddates = new List <DateTime>(); using (SA45Team12AD entities = new SA45Team12AD()) { //get list of current delegates delegatelist = entities.DDelegateDetails.ToList(); deplist = entities.Departments.ToList(); foreach (Department u in deplist) { if (u.HasDelegate == 1) { depwithdelegateslist.Add(u); } } if (depwithdelegateslist != null) { foreach (Department u in depwithdelegateslist) { delegatelist.Add(RequisitionLogic.GetLatestDelegate(u.DeptID)); } foreach (DDelegateDetail u in delegatelist) { //get username for delegates string username = DisbursementLogic.GetUserName(u.DepartmentHeadDelegate, u.DepartmentID); //remove depthead role from user after checking period if (DateTime.Today > u.EndDate && Roles.IsUserInRole(username, "HOD")) { RequisitionLogic.RemoveDeptHeadRoleFromUser(u.DepartmentHeadDelegate, u.DepartmentID); Department department = entities.Departments.Where(x => x.DeptID == u.DepartmentID).First(); department.HasDelegate = 0; entities.SaveChanges(); } } } } }
// Processing requisition requests by DEPARTMENT HEAD public static string ProcessRequsitionRequest(int reqID, string status, string approverName, string remarks) { using (SA45Team12AD context = new SA45Team12AD()) { // Updating the status of all items in the request List <RequisitionRecordDetail> rd = context.RequisitionRecordDetails.Where(x => x.RequestID == reqID).ToList(); RequisitionRecord r = context.RequisitionRecords.Where(x => x.RequestID == reqID).First(); try { // Updating the status in the ReqDetails table foreach (var item in rd) { item.Status = status; } // Updating the reques in ReqRecords table r.ApprovedDate = DateTime.Now; r.ApproverName = approverName; if (!String.IsNullOrWhiteSpace(remarks)) { r.Remarks = remarks; } // Confirming changes to the DB context.SaveChanges(); } catch (Exception) { return(("Procedure was unsuccessful.").ToString()); } if (status.Equals("Approved")) { return(("Request R" + reqID + ", was successfully approved.").ToString()); } else { return(("Request R" + reqID + ", was successfully rejected.").ToString()); } } }
// Setting automated buffer stock handling --- Auto is set to 10% public static void SetAutomatedlBFS(string itemID) { using (SA45Team12AD context = new SA45Team12AD()) { // Finding the week no for the year (aka our period currently) DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; int currentPeriod = cal.GetWeekOfYear(DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek); // Creating our obj from DB ForecastedData f = context.ForecastedDatas.Where(x => x.ItemID.Equals(itemID)).Where(y => y.Season == DateTime.Now.Year).Where(z => z.Period == currentPeriod + 1).First(); InventoryCatalogue i = context.InventoryCatalogues.Where(x => x.ItemID.Equals(itemID)).First(); // Changing our values i.BFSProportion = 10; i.BufferStockLevel = Convert.ToInt32(Math.Ceiling((10.0 * Convert.ToDouble(f.High95)) / 100)); // We take high95 cos it possesses the expected Dd with the highest confidence interval determinable (just to be safe) context.SaveChanges(); } }
// Setting a proportional level for buffer stock public static void SetProportionalBFS(string itemID, int propValue) { using (SA45Team12AD context = new SA45Team12AD()) { // Finding the week no for the year (aka our period currently) DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; int currentPeriod = cal.GetWeekOfYear(DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek); // Creating our obj from DB ForecastedData f = context.ForecastedDatas.Where(x => x.ItemID.Equals(itemID)).Where(y => y.Season == DateTime.Now.Year).Where(z => z.Period == currentPeriod + 1).First(); // +1 to capture the next period InventoryCatalogue i = context.InventoryCatalogues.Where(x => x.ItemID.Equals(itemID)).First(); // Changing our values i.BFSProportion = propValue; i.BufferStockLevel = Convert.ToInt32(Math.Ceiling((Convert.ToDouble(propValue) * Convert.ToDouble(f.ForecastedDemand)) / 100)); context.SaveChanges(); } }
public int CreateDisbursementList(string deptId, int collectPtId, DateTime collectionDate, string deptRep) { DisbursementList dList = new DisbursementList(); using (SA45Team12AD ctx = new SA45Team12AD()) { dList.DepartmentID = deptId; dList.CollectionPointID = collectPtId; dList.CollectionDate = collectionDate; dList.RepresentativeName = deptRep; dList.Status = "Pending Collection"; ctx.DisbursementLists.Add(dList); ctx.SaveChanges(); } using (EmailControl em = new EmailControl()) { em.NewStationeryCollectionNotification(Utility.Utility.GetEmailAddressByName(deptRep), GetCurrentCPWithTimeByID(collectPtId), collectionDate.ToString("d")); } return(dList.DisbursementID); }