public ActionResult View(int?id) { var repo = new PurchaseRequestRepository(); PurchaseRequest model = repo.GetPurchaseRequestHDDetails(id ?? 0); var PRList = repo.GetPurchaseRequestDTDetails(id ?? 0); model.items = new List <PurchaseRequestItem>(); foreach (var item in PRList) { var pritem = new PurchaseRequestItem { PartNo = item.PartNo, ItemName = item.ItemName, Quantity = item.Quantity, UnitName = item.UnitName, ItemId = item.ItemId, MinLevel = item.MinLevel, WRRequestQty = item.WRRequestQty, CurrentStock = item.CurrentStock, WRIssueQty = item.WRIssueQty, TotalQty = item.TotalQty, InTransitQty = item.InTransitQty, PendingPRQty = item.PendingPRQty, ShortorExcess = item.ShortorExcess, Remarks = item.Remarks }; model.items.Add(pritem); } return(View("View", model)); }
public ActionResult Delete(int Id) { ViewBag.Title = "Delete"; var result1 = new PurchaseRequestRepository().CHECK(Id); if (result1 > 0) { TempData["error"] = "Sorry!!..Already Used!!"; TempData["PurchaseRequestNo"] = null; return(RedirectToAction("Edit", new { id = Id })); } else { var result2 = new PurchaseRequestRepository().DeletePurchaseRequestDT(Id); var result3 = new PurchaseRequestRepository().DeletePurchaseRequestHD(Id, UserID.ToString()); if (Id > 0) { TempData["Success"] = "Deleted Successfully!"; //return RedirectToAction("PreviousList"); return(RedirectToAction("Index")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["PurchaseRequestNo"] = null; return(RedirectToAction("Edit", new { id = Id })); } } }
public ActionResult Create(int?WorkShopRequestId) { PurchaseRequestRepository repo = new PurchaseRequestRepository(); PurchaseRequest model = repo.GetPurchaseRequestDetails(WorkShopRequestId ?? 0); var PRList = repo.GetPurchaseRequestItem(WorkShopRequestId ?? 0); model.items = new List <PurchaseRequestItem>(); foreach (var item in PRList) { var pritem = new PurchaseRequestItem { PartNo = item.PartNo, ItemName = item.ItemName, Quantity = item.Quantity, UnitName = item.UnitName, ItemId = item.ItemId, MinLevel = item.MinLevel, WRRequestQty = item.WRRequestQty, CurrentStock = item.CurrentStock, WRIssueQty = item.WRIssueQty, TotalQty = item.TotalQty, InTransitQty = item.InTransitQty, PendingPRQty = item.PendingPRQty, ShortorExcess = item.ShortorExcess }; model.items.Add(pritem); } string internalId = ""; try { internalId = DatabaseCommonRepository.GetNextDocNo(8, OrganizationId); } catch (NullReferenceException nx) { TempData["success"] = ""; TempData["error"] = "Some required data was missing. Please try again.|" + nx.Message; } catch (Exception ex) { TempData["success"] = ""; TempData["error"] = "Some error occurred. Please try again.|" + ex.Message; } model.PurchaseRequestNo = internalId; model.PurchaseRequestDate = System.DateTime.Today; model.RequiredDate = System.DateTime.Today; model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); return(View(model)); }
public ActionResult GetLastPurchaseRate(int itemId) { try { var list = new PurchaseRequestRepository().GetLastPurchaseRate(itemId, OrganizationId); return(PartialView("_LastPurchaseRateGrid", list)); } catch (Exception) { return(Json("Some error occurred while fetching the rates!", JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(PurchaseRequest model) { ViewBag.Title = "Edit"; model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new PurchaseRequestRepository(); var result1 = new PurchaseRequestRepository().CHECK(model.PurchaseRequestId); if (result1 > 0) { TempData["error"] = "Sorry!!..Already Used!!"; TempData["PurchaseRequestNo"] = null; return(RedirectToAction("Index")); } else { try { //var result2 = new PurchaseRequestRepository().DeletePurchaseRequestDT(model.PurchaseRequestId); //var result3 = new PurchaseRequestRepository().DeletePurchaseRequestHD(model.PurchaseRequestId, UserID.ToString()); var result = new PurchaseRequestRepository().UpdatePurchaseRequest(model); //string id = new PurchaseRequestRepository().InsertPurchaseRequest(model); if (result != "") { TempData["success"] = "Updated successfully. (" + result + ")"; TempData["error"] = ""; return(RedirectToAction("Index")); //return View("Edit", model); } else { throw new Exception(); } } catch (SqlException sx) { TempData["error"] = "Some error occured while connecting to database. Please check your network connection and try again."; } catch (NullReferenceException nx) { TempData["error"] = "Some required data was missing. Please try again."; } catch (Exception ex) { TempData["error"] = "Some error occured. Please try again."; } return(RedirectToAction("Index")); } }
public ActionResult GetLastPurchaseRate(int item) { try { var list = new PurchaseRequestRepository().GetLastPurchaseRate(item, OrganizationId); return(PartialView("_LastPurchaseRate", list)); } catch (Exception) { TempData["error"] = "Some error occurred while loading the report. Please try again."; return(Json(TempData["error"], JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(PurchaseRequest model) { try { if (!ModelState.IsValid) { return(View(model)); } model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string id = new PurchaseRequestRepository().InsertPurchaseRequest(model); if (id.Split('|')[0] != "0") { TempData["success"] = "Saved successfully. Purchase Request Reference No. is " + id.Split('|')[1]; TempData["error"] = ""; return(RedirectToAction("Pending")); } else { throw new Exception(); } } catch (SqlException sx) { TempData["error"] = "Some error occured while connecting to database. Please check your network connection and try again.|" + sx.Message; } catch (NullReferenceException nx) { TempData["error"] = "Some required data was missing. Please try again.|" + nx.Message; } catch (Exception ex) { TempData["error"] = "Some error occured. Please try again.|" + ex.Message; } return(RedirectToAction("Pending")); }
public ActionResult Print(int Id) { ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "PurchaseRequest.rpt")); DataSet ds = new DataSet(); ds.Tables.Add("Head"); ds.Tables.Add("Items"); //-------HEAD ds.Tables["Head"].Columns.Add("PurchaseRequestNo"); ds.Tables["Head"].Columns.Add("PurchaseRequestDate"); ds.Tables["Head"].Columns.Add("WorkShopRequestId"); ds.Tables["Head"].Columns.Add("CustomerName"); //ds.Tables["Head"].Columns.Add("CustomerName"); ds.Tables["Head"].Columns.Add("SpecialRemarks"); ds.Tables["Head"].Columns.Add("RequiredDate"); ds.Tables["Head"].Columns.Add("CustomerOrderRef"); ds.Tables["Head"].Columns.Add("WorkShopRequestRefNo"); ds.Tables["Head"].Columns.Add("DoorNo"); ds.Tables["Head"].Columns.Add("Street"); ds.Tables["Head"].Columns.Add("State"); ds.Tables["Head"].Columns.Add("Country"); ds.Tables["Head"].Columns.Add("Phone"); ds.Tables["Head"].Columns.Add("Fax"); ds.Tables["Head"].Columns.Add("Email"); ds.Tables["Head"].Columns.Add("ContactPerson"); ds.Tables["Head"].Columns.Add("Zip"); ds.Tables["Head"].Columns.Add("OrganizationName"); ds.Tables["Head"].Columns.Add("Image1"); ds.Tables["Head"].Columns.Add("CreatedUser"); ds.Tables["Head"].Columns.Add("CreateSignature"); //-------DT ds.Tables["Items"].Columns.Add("PartNo"); ds.Tables["Items"].Columns.Add("ItemName"); ds.Tables["Items"].Columns.Add("Quantity"); ds.Tables["Items"].Columns.Add("UnitName"); ds.Tables["Items"].Columns.Add("ItemId"); ds.Tables["Items"].Columns.Add("MinLevel"); ds.Tables["Items"].Columns.Add("WRRequestQty"); ds.Tables["Items"].Columns.Add("CurrentStock"); ds.Tables["Items"].Columns.Add("WRIssueQty"); ds.Tables["Items"].Columns.Add("TotalQty"); ds.Tables["Items"].Columns.Add("InTransitQty"); ds.Tables["Items"].Columns.Add("PendingPRQty"); ds.Tables["Items"].Columns.Add("ShortorExcess"); ds.Tables["Items"].Columns.Add("Remarks"); PurchaseRequestRepository repo = new PurchaseRequestRepository(); var Head = repo.GetPurchaseRequestHDDetailsPrint(Id, OrganizationId); DataRow dr = ds.Tables["Head"].NewRow(); dr["PurchaseRequestNo"] = Head.PurchaseRequestNo; dr["PurchaseRequestDate"] = Head.PurchaseRequestDate.ToString("dd-MMM-yyyy"); dr["WorkShopRequestId"] = Head.WorkShopRequestId; dr["CustomerName"] = Head.CustomerName; dr["SpecialRemarks"] = Head.SpecialRemarks; dr["RequiredDate"] = Head.RequiredDate.ToString("dd-MMM-yyyy");; dr["CustomerOrderRef"] = Head.CustomerOrderRef; dr["WorkShopRequestRefNo"] = Head.WorkShopRequestRefNo; dr["DoorNo"] = Head.DoorNo; dr["Street"] = Head.Street; dr["State"] = Head.State; dr["Country"] = Head.CountryName; dr["Phone"] = Head.Phone; dr["Fax"] = Head.Fax; dr["Email"] = Head.Email; dr["ContactPerson"] = Head.ContactPerson; dr["Zip"] = Head.Zip; dr["OrganizationName"] = Head.OrganizationName; dr["Image1"] = Server.MapPath("~/App_images/") + Head.Image1; dr["CreatedUser"] = Head.CreatedUser; dr["CreateSignature"] = Server.MapPath("~/App_Images/") + Head.CreatedUsersig; ds.Tables["Head"].Rows.Add(dr); PurchaseRequestRepository repo1 = new PurchaseRequestRepository(); var Items = repo1.PurchaseRequestItemDetailsPrint(Id); foreach (var item in Items) { var pritem = new PurchaseRequestItem { PartNo = item.PartNo, ItemName = item.ItemName, Quantity = item.Quantity, UnitName = item.UnitName, ItemId = item.ItemId, MinLevel = item.MinLevel, WRRequestQty = item.WRRequestQty, CurrentStock = item.CurrentStock, WRIssueQty = item.WRIssueQty, TotalQty = item.TotalQty, InTransitQty = item.InTransitQty, PendingPRQty = item.PendingPRQty, ShortorExcess = item.ShortorExcess, Remarks = item.Remarks }; DataRow dri = ds.Tables["Items"].NewRow(); dri["PartNo"] = pritem.PartNo; dri["ItemName"] = pritem.ItemName; dri["Quantity"] = pritem.Quantity; dri["UnitName"] = pritem.UnitName; dri["ItemId"] = pritem.ItemId; dri["MinLevel"] = pritem.MinLevel; dri["WRRequestQty"] = pritem.WRRequestQty; dri["CurrentStock"] = pritem.CurrentStock; dri["WRIssueQty"] = pritem.WRIssueQty; dri["TotalQty"] = pritem.TotalQty; dri["InTransitQty"] = pritem.InTransitQty; dri["PendingPRQty"] = pritem.PendingPRQty; dri["ShortorExcess"] = pritem.ShortorExcess; dri["Remarks"] = pritem.Remarks; ds.Tables["Items"].Rows.Add(dri); } ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "PurchaseRequest.xml"), XmlWriteMode.WriteSchema); rd.SetDataSource(ds); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", String.Format("PurchaseRequest{0}.pdf", Id.ToString()))); } catch (Exception ex) { throw; } }
public void notify(int id, string status, string note) { PurchaseRequestRepository.notify(id, status, note); }
public ActionResult Print() { ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "PendingPARregister.rpt")); DataSet ds = new DataSet(); ds.Tables.Add("Head"); ds.Tables.Add("Items"); //-------HEAD ds.Tables["Head"].Columns.Add("OrganizationName"); ds.Tables["Head"].Columns.Add("Image1"); //-------DT ds.Tables["Items"].Columns.Add("Request No."); ds.Tables["Items"].Columns.Add("Date"); ds.Tables["Items"].Columns.Add("Material"); ds.Tables["Items"].Columns.Add("Remarks"); ds.Tables["Items"].Columns.Add("Request Qty"); ds.Tables["Items"].Columns.Add("GRN Qty"); ds.Tables["Items"].Columns.Add("Settled Qty"); ds.Tables["Items"].Columns.Add("Balance Qty"); PurchaseRequestRepository repo = new PurchaseRequestRepository(); var Head = repo.PurchaseRequestRegisterHD(OrganizationId); DataRow dr = ds.Tables["Head"].NewRow(); dr["OrganizationName"] = Head.OrganizationName; dr["Image1"] = Server.MapPath("~/App_images/") + Head.Image1; ds.Tables["Head"].Rows.Add(dr); PurchaseRequestRepository repo1 = new PurchaseRequestRepository(); var Items = repo1.GetPendingPARregisterDT(OrganizationId); foreach (var item in Items) { var PurchaseRequestRegItem = new PurchaseRequestRegister { PurchaseRequestNo = item.PurchaseRequestNo, PurchaseRequestDate = item.PurchaseRequestDate, ItemName = item.ItemName, Remarks = item.Remarks, ReqQty = item.ReqQty, GRNQTY = item.GRNQTY, SettledQty = item.SettledQty, BALQTY = item.BALQTY }; DataRow dri = ds.Tables["Items"].NewRow(); dri["Request No."] = PurchaseRequestRegItem.PurchaseRequestNo; dri["Date"] = PurchaseRequestRegItem.PurchaseRequestDate.ToString("dd-MMM-yyyy"); dri["Material"] = PurchaseRequestRegItem.ItemName; dri["Remarks"] = PurchaseRequestRegItem.Remarks; dri["Request Qty"] = PurchaseRequestRegItem.ReqQty; dri["GRN Qty"] = PurchaseRequestRegItem.GRNQTY; dri["Settled Qty"] = PurchaseRequestRegItem.SettledQty; dri["Balance Qty"] = PurchaseRequestRegItem.BALQTY; ds.Tables["Items"].Rows.Add(dri); } ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "PendingPARregister.xml"), XmlWriteMode.WriteSchema); rd.SetDataSource(ds); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", String.Format("PendingPARregister.pdf"))); } catch (Exception ex) { throw; } }
public void update(int id) { PurchaseRequestRepository.update(id); }
public PurchaseRequest find(int id) { return(PurchaseRequestRepository.find(id)); }
public List <PurchaseRequest> getAll() { return(PurchaseRequestRepository.getAll()); }
public void add(int departmentID, string information) { PurchaseRequest p = PurchaseRequestFactory.create(departmentID, information); PurchaseRequestRepository.add(p); }
public ActionResult LoadQuickView() { if (Session["user"] == null) { return(RedirectToAction("LogOff", "Account")); } QuickView view = new QuickView(); view.PendingDirectPurchaseRequests = true; view.PendingTransQuotations = true; view.PendingProjectQuotations = true; view.PendingSupplyOrders = true; view.PendingWorkshopRequests = true; view.PendingProjectSaleOrdersForJobCard = true; view.PendingTransSaleOrdersForJobCard = true; view.MaterialStockBelowMinLevel = true; view.PendingVechicleInpass = true; view.PendingWRForStoreIssue = true; view.PendingJobcardQC = true; view.PendingMaterialReqPRS = true; if (view.PendingProjectQuotations) { SalesQuotationRepository repo = new SalesQuotationRepository(); var res = repo.GetSalesQuotationApproveList(1, 0, OrganizationId); view.NoOfProjectQuotations = res.Count; } if (view.PendingTransQuotations) { SalesQuotationRepository repo = new SalesQuotationRepository(); var res = repo.GetSalesQuotationApproveList(0, 0, OrganizationId); view.NoOfTransQuotations = res.Count; } if (view.PendingSupplyOrders) { var repo = new GRNRepository(); var res = repo.GetGRNPendingList(0); view.NoOfSupplyOrders = res.Count(); } if (view.PendingDirectPurchaseRequests) { var res = new DirectPurchaseRepository().GetUnApprovedRequests(UserID); view.NoOfPurchaseRequests = res.Count; } if (view.PendingWorkshopRequests) { var rep = new SaleOrderRepository(); var slist = rep.GetSaleOrdersPendingWorkshopRequest(OrganizationId, 0); view.NoOfWorkShopRequests = slist.Count; } if (view.PendingProjectSaleOrdersForJobCard) { var list = new JobCardRepository().GetPendingSO(1, OrganizationId, 0); view.NoOfProjectSaleOrdersForJobCard = list.Count(); } if (view.PendingTransSaleOrdersForJobCard) { var list = new JobCardRepository().GetPendingSO(0, OrganizationId, 0); view.NoOfTransSaleOrdersForJobCard = list.Count(); } if (view.MaterialStockBelowMinLevel) { var list = new ItemRepository().GetCriticalMaterialsBelowMinStock(OrganizationId); view.NoOfMaterialStockBelowMinLevel = list.Count(); //view.NoOfMaterialStockBelowMinLevel = new ItemRepository().GetCriticalMaterialsBelowMinStock(OrganizationId); } if (view.PendingVechicleInpass) { var list = new VehicleInPassRepository().PendingVehicleInpassforAlert(OrganizationId); view.NoOfVechicleInpass = list.Count(); } if (view.PendingWRForStoreIssue) { var list = new WorkShopRequestRepository().PendingWorkshopRequests("", "", "", ""); view.NoOfWRForStoreIssue = list.Count(); } if (view.PendingJobcardQC) { var list = new DeliveryChallanRepository().PendingDelivery(OrganizationId); view.NoOfJobcardQC = list.Count(); } if (view.PendingMaterialReqPRS) { var list = new PurchaseRequestRepository().GetWorkShopRequestPending(OrganizationId, 0, "", "all"); view.NoOfPendingMaterialReqPRS = list.Count(); } IEnumerable <ERPAlerts> Alerts; if (Session["alertpermissions"] == null) { UserRepository repo = new UserRepository(); Alerts = repo.GetAlerts(UserID); Session["alertpermissions"] = Alerts; } else { Alerts = (IEnumerable <ERPAlerts>)Session["alertpermissions"]; Session["alertpermissions"] = Alerts; } AlertPermission alertpermission = new AlertPermission(); foreach (var item in Alerts) { if (item.HasPermission == 1) { switch (item.AlertId) { case 1: alertpermission.ProjectQuotApproval = true; break; case 2: alertpermission.TransportQuotApproval = true; break; case 3: alertpermission.PendingSupplyOrdForGrn = true; break; case 4: alertpermission.DirectPurchaseReqDorApproval = true; break; case 5: alertpermission.PendingSOForWorkshopReq = true; break; //case 6: // alertpermission.PendingProjectSaleOrdersForJobCard = true; // break; //case 7: // alertpermission.PendingTransSaleOrdersForJobCard = true; // break; case 6: alertpermission.MaterialStockBelowMinLevel = true; break; case 7: alertpermission.PendingVechicleInpass = true; break; case 8: alertpermission.PendingWRForStoreIssue = true; break; case 9: alertpermission.PendingJobcardQC = true; break; case 10: alertpermission.PendingMaterialReqPRS = true; break; default: break; } } } ViewBag.AlertPermissions = alertpermission; return(PartialView("_QuickView", view)); }