public List <WorkShopRequest> GetWorkshopRequest() { List <WorkShopRequest> Ls; Ls = new List <WorkShopRequest>(); string cmdStr = @"SELECT tbl_User.UserId, tbl_User.UserName_Email,tbl_WorkShop.WorkShopId, tbl_WorkShop.WorkShopTitle, tbl_Student_WorkShop_Mapping.IsApproved FROM tbl_Student_WorkShop_Mapping Left outer JOIN tbl_User ON tbl_User.UserId = tbl_Student_WorkShop_Mapping.StudentId Left outer JOIN tbl_WorkShop ON tbl_Student_WorkShop_Mapping.WorkShopId = tbl_WorkShop.WorkShopId "; SqlConnection con = new SqlConnection(conStr); SqlCommand cmd = new SqlCommand(cmdStr, con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { WorkShopRequest Wp = new WorkShopRequest(); Wp.UserId = int.Parse(dr["UserId"].ToString()); Wp.UserName_Email = dr["UserName_Email"].ToString(); Wp.WorkShopId = int.Parse(dr["WorkShopId"].ToString()); Wp.WorkShopTitle = dr["WorkShopTitle"].ToString(); Wp.IsApproved = (dr["IsApproved"].ToString() == "") ? false : bool.Parse(dr["IsApproved"].ToString()); Ls.Add(Wp); } dr.Close(); con.Close(); return(Ls); }
public ActionResult Save(WorkShopRequest model) { try { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string id = new WorkShopRequestRepository().InsertWorkShopRequest(model); if (id.Split('|')[0] != "0") { TempData["success"] = "Saved successfully. WorkShop Request Reference No. is " + id.Split('|')[1]; TempData["error"] = ""; return(RedirectToAction("Pending", new { model.isProjectBased })); } 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(View("Pending", model)); }
public ActionResult Create(WorkShopRequest model) { try { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); if (new WorkShopRequestRepository().InsertAdditionalWorkshopRequest(model) > 0) { TempData["success"] = "Saved succesfully"; TempData["error"] = ""; return(RedirectToAction("Create", new { model.isProjectBased })); } } catch (NullReferenceException nx) { TempData["success"] = ""; TempData["error"] = "Some required value was missing. Please try again.|" + nx.Message; } catch (Exception ex) { TempData["success"] = ""; TempData["error"] = "Some error occured. Please try again.|" + ex.Message; } JobCardDropdown(model.isProjectBased); return(View("Create", model)); }
public ActionResult Create(int?SaleOrderId, int?saleorderitem) { ItemDropdown(); ExceptFGItemDropdown(); WorkShopRequestRepository repo = new WorkShopRequestRepository(); WorkShopRequest model = repo.GetSaleOrderForWorkshopRequest(SaleOrderId ?? 0); model.SaleOrderItemId = saleorderitem ?? 0; model.WorkDescription = repo.GetCombinedWorkDescriptionSaleOrderForWorkshopRequest(SaleOrderId ?? 0).WorkDescription; List <WorkShopRequestItem> WSList = new List <WorkShopRequestItem>(); if (model.isProjectBased == 1) { WSList = repo.GetWorkShopRequestDataForProject(saleorderitem ?? 0); } else { WSList = repo.GetWorkShopRequestData(SaleOrderId ?? 0, saleorderitem ?? 0); } model.Items = new List <WorkShopRequestItem>(); //model.Isused = true; foreach (var item in WSList) { model.Items.Add(new WorkShopRequestItem { PartNo = item.PartNo, ItemName = item.ItemName, Quantity = item.Quantity, UnitName = item.UnitName, ItemId = item.ItemId, ActualQuantity = item.Quantity }); } string internalId = ""; try { if (model.isProjectBased == 0) { internalId = DatabaseCommonRepository.GetNextDocNo(19, OrganizationId); } else { internalId = DatabaseCommonRepository.GetNextDocNo(31, 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.WorkShopRequestRefNo = internalId; model.WorkShopRequestDate = System.DateTime.Today; model.RequiredDate = System.DateTime.Today; return(View(model)); }
public ActionResult Edit(int?id) { ItemDropdown(); ExceptFGItemDropdown(); var repo = new WorkShopRequestRepository(); WorkShopRequest model = repo.GetWorkshopRequestHdData(id ?? 0); model.Items = repo.GetWorkShopRequestDtData(id ?? 0); return(View("Edit", model)); }
public PartialViewResult AdditionalItemsList() { ItemDropdown(); FillPartNo(); WorkShopRequest workShopRequest = new WorkShopRequest { Items = new List <WorkShopRequestItem>() }; workShopRequest.Items.Add(new WorkShopRequestItem()); return(PartialView("_AdditionalItemsList", workShopRequest)); }
public ActionResult Edit(int id = 0) { try { if (id != 0) { ItemDropdown(); FillPartNo(); WorkShopRequest WorkShopRequest = new WorkShopRequest(); WorkShopRequest = new WorkShopRequestRepository().WorkShopRequestHD(id); JobCardDropdown(WorkShopRequest.isProjectBased); WorkShopRequest.Items = new WorkShopRequestItemRepository().WorkShopRequestDT(id); return(View("Edit", WorkShopRequest)); } else { TempData["error"] = "That was an invalid/unknown request. Please try again."; TempData["success"] = ""; } } catch (InvalidOperationException iox) { TempData["error"] = "Sorry, we could not find the requested item. Please try again.|" + iox.Message; } catch (SqlException sx) { TempData["error"] = "Some error occured while connecting to database. Please try again after sometime.|" + 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; } TempData["success"] = ""; return(RedirectToAction("Index")); }
public ActionResult EditDirectMaterialRequest(WorkShopRequest model) { try { model.CreatedBy = UserID.ToString(); model.CreatedDate = DateTime.Today; var success = new WorkShopRequestRepository().UpdateDirectMaterialRequest(model); if (success <= 0) { throw new Exception(); } TempData["success"] = "Updated successfully (" + model.WorkShopRequestRefNo + ")"; return(RedirectToAction("DirectMaterialRequestList")); } catch (Exception) { TempData["error"] = "Some error occured while saving. Please try again."; FillPartNo(); GetMaterials(); return(View("CreateDirectMaterialRequest", model)); } }
public ActionResult Edit(WorkShopRequest model) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new WorkShopRequestRepository(); try { new WorkShopRequestRepository().UpdateWorkShopRequest(model); TempData["success"] = "Updated Successfully (" + model.WorkShopRequestRefNo + ")"; return(RedirectToAction("Index", new { isProjectBased = model.isProjectBased })); } catch (Exception) { TempData["error"] = "Some error occurred. Please try again."; } return(RedirectToAction("Index", new { isProjectBased = model.isProjectBased })); }
public ActionResult CreateDirectMaterialRequest(WorkShopRequest model) { try { model.CreatedBy = UserID.ToString(); model.OrganizationId = OrganizationId; model.CreatedDate = DateTime.Today; string ref_no = new WorkShopRequestRepository().InsertDirectMaterialRequest(model); if (ref_no.Length > 0) { TempData["success"] = "Saved Successfully. Reference No. is " + model.WorkShopRequestRefNo; return(RedirectToAction("CreateDirectMaterialRequest")); } else { throw new Exception(); } } catch (Exception) { TempData["error"] = "Some error occurred while saving. Please try again."; return(View(model)); } }