public PartialViewResult PendingWorkshopRequestDetails() { StoreIssue _model = new StoreIssue { Items = new StoreIssueRepository().PendingWorkshopRequestItems(Convert.ToInt32(Request.QueryString["id"])).ToList() }; return(PartialView("_IssuanceItems", _model)); }
public ActionResult Issuance(StoreIssue model) { try { List <int> temp = (from StoreIssueItem i in model.Items where i.CurrentIssuedQuantity > 0 select i.StoreIssueId).ToList(); List <StoreIssueItem> items = model.Items.Where(m => m.CurrentIssuedQuantity > 0).ToList(); if (temp.Count == 0) { TempData["error"] = "Atleast one of the quantities must be greater than zero"; goto ReturnSameView; } model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string result = new StoreIssueRepository().InsertStoreIssue(model); if (result.Length != 0) //if insert success { TempData["success"] = "Saved succesfully. Reference No. is " + result; 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; } ReturnSameView: FillDropdowns(); TempData["success"] = ""; return(View(model)); //if insert fails }
public ActionResult Edit(int id = 0) { try { if (id != 0) { FillDropdowns(); StoreIssue StoreIssue = new StoreIssue(); StoreIssue = new StoreIssueRepository().GetStoreIssueHD(id); StoreIssue.Items = new StoreIssueItemRepository().GetStoreIssueDT(id); return(View(StoreIssue)); } 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 string InsertStoreIssue(StoreIssue objStoreIssue) { try { using (IDbConnection connection = OpenConnection(dataConnection)) { IDbTransaction txn = connection.BeginTransaction(); try { string referenceNo = DatabaseCommonRepository.GetNewDocNo(connection, objStoreIssue.OrganizationId, 24, true, txn); objStoreIssue.StoreIssueRefNo = referenceNo; string sql = @" INSERT INTO StoreIssue( StoreIssueRefNo,StoreIssueDate,StockPointId,WorkShopRequestId,EmployeeId, Remarks,CreatedBy,CreatedDate,OrganizationId,isActive) VALUES ( @StoreIssueRefNo,@StoreIssueDate,@StockPointId,@WorkShopRequestId,@EmployeeId, @Remarks,@CreatedBy,@CreatedDate,@OrganizationId,1); SELECT CAST(SCOPE_IDENTITY() AS INT)"; var id = connection.Query <int>(sql, objStoreIssue, txn).Single(); foreach (var item in objStoreIssue.Items) { if (item.CurrentIssuedQuantity != 0) { item.StoreIssueId = id; new StoreIssueItemRepository().InsertStoreIssueItem(item, connection, txn); new StockUpdateRepository().InsertStockUpdate(new StockUpdate { OrganizationId = objStoreIssue.OrganizationId, CreatedBy = objStoreIssue.CreatedBy, CreatedDate = objStoreIssue.CreatedDate, StockPointId = objStoreIssue.StockpointId, StockType = "StoreIssue", StockInOut = "OUT", stocktrnDate = System.DateTime.Today, ItemId = item.ItemId, Quantity = item.CurrentIssuedQuantity * (-1), StocktrnId = id, StockUserId = objStoreIssue.StoreIssueRefNo }, connection, txn); } } InsertLoginHistory(dataConnection, objStoreIssue.CreatedBy, "Create", "Store Issue", id.ToString(), "0"); txn.Commit(); return(referenceNo); } catch (Exception ex) { txn.Rollback(); throw ex; } } } catch (SqlException sx) { throw sx; } catch (Exception ex) { throw ex; } }