// 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); } } }
//------------ 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); }
// 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); } } }
protected void BindGird(int poNo) { PORecord poRecord = PurchasingLogic.GetPurchaseOrderRecord(poNo); List <PORecordDetail> poRecordDetaillist = PurchasingLogic.GetListOfPORecorDetails(poNo); RequestOrProcessedView(poRecord); GridViewVPO.DataSource = poRecordDetaillist; GridViewVPO.DataBind(); }
protected void RequestOrProcessedView(PORecord poRecord) { LblRst.Text = poRecord.CreatedBy; LblStatus.Text = poRecord.Status; LblDeliver.Text = poRecord.CreatedBy; LblAddress.Text = poRecord.DeliveryAddress; LblSupplier.Text = PurchasingLogic.ListSuppliers().Where(x => x.SupplierID == poRecord.SupplierID).Select(x => x.SupplierName).FirstOrDefault(); LblSupply.Text = ((DateTime)poRecord.ExpectedDelivery).ToString("d"); LblNumber.Text = poRecord.PONumber.ToString(); }
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 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); }
void DisplayLabels(int pONumber) { PORecord poR = PurchasingLogic.ListPORecords().Where(x => x.PONumber == pONumber).FirstOrDefault(); LblNumbeer.Text = pONumber.ToString(); LblDate.Text = ((DateTime)poR.DateRequested).ToString("d"); LblStatus.Text = poR.Status; LblDeliver.Text = poR.RecipientName; LblAddress.Text = poR.DeliveryAddress; LblRequest.Text = poR.CreatedBy; LblCode.Text = PurchasingLogic.ListSuppliers().Where(x => x.SupplierID == poR.SupplierID).Select(x => x.SupplierName).FirstOrDefault(); if (poR.Status != "Pending") { btnapr.Visible = false; btncancel.Visible = false; } }
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 BtnPostGR_Click(object sender, EventArgs e) { if (!ValidQty()) { return; } DateTime date = DateTime.ParseExact(Request.Form["datepicker"], "dd/MM/yyyy", CultureInfo.InvariantCulture); string clerkName = HttpContext.Current.Profile.GetPropertyValue("fullname").ToString(); string doNumber = TxtDoNumber.Text; int poNumber = int.Parse(HiddenFieldPONumber.Value.ToString()); PurchasingLogic pl = new PurchasingLogic(); InventoryLogic il = new InventoryLogic(); PORecord pr = pl.GetPORecords(poNumber); if (!Utility.Validator.IsDateRangeValid(date, DateTime.Now.Date, true)) { statusMessage.Text = "Error! You cannot make a future date Goods Receipt!"; statusMessage.ForeColor = Color.Red; statusMessage.Visible = true; return; } int grNumber = pl.CreateGoodsReceipt(date, poNumber, clerkName, doNumber); foreach (GridViewRow r in GridViewGR.Rows) { string itemID = (r.FindControl("LblItemCode") as Label).Text; int quantity = int.Parse((r.FindControl("TxtQty") as TextBox).Text); string uom = (r.FindControl("LblUom") as Label).Text; string remarks = (r.FindControl("TxtRemarks") as TextBox).Text; pl.CreateGoodsReceiptDetails(grNumber, itemID, quantity, uom, remarks); string stockCardDesc = "Goods Receipt - GR" + grNumber.ToString("0000") + " Supplier " + pr.SupplierID; il.UpdateStockCard(stockCardDesc, itemID, date, "Add", quantity, uom); } //Here will check if the PO is already completed pl.GetPurchaseOrdersForGR(poNumber); poNumber = -1; LblQtyValid.Visible = false; DisplaySuccessMessage(grNumber); DisplayEmptyGrid(); }