public void FillCurrency() { var repo = new PurchaseBillRepository(); var list = repo.FillCurrency(); ViewBag.currlist = new SelectList(list, "Id", "Name"); }
public ActionResult Delete(int Id) { ViewBag.Title = "Delete"; //var result1 = new SupplyOrderRepository().CHECK(Id); //if (result1 > 0) //{ // TempData["error"] = "Sorry!!..Already Used!!"; // TempData["SupplyOrderNo"] = null; // return RedirectToAction("Edit", new { id = Id }); //} //else //{ var result2 = new PurchaseBillRepository().DeletePuchaseBillDT(Id); var result3 = new PurchaseBillRepository().DeletePuchaseBillHD(Id, UserID.ToString()); if (Id > 0) { TempData["Success"] = "Deleted Successfully!"; //return RedirectToAction("PreviousList"); return(RedirectToAction("PurchaseBillList")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["SupplyOrderNo"] = null; return(RedirectToAction("Edit", new { id = Id })); } }
public ActionResult Create(IList <PendingGRN> PendingGRNSelected) { FillAdditionDeduction(); FillCurrency(); PurchaseBill purchasebill = new PurchaseBill(); PurchaseBillRepository rep = new PurchaseBillRepository(); if (PendingGRNSelected != null) { if (PendingGRNSelected.Count > 0) { List <int> selectedgrn = (from PendingGRN p in PendingGRNSelected where p.Select select p.GRNId).ToList <int>(); purchasebill = rep.GetGRNHeadData(selectedgrn); purchasebill.Items = rep.GetGRNItems(selectedgrn); purchasebill.SupplyOrderNo = rep.GetSupplyOrderNos(selectedgrn).SupplyOrderNo; } } string internalId = ""; try { internalId = DatabaseCommonRepository.GetNextDocNo(32, 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; } try { purchasebill.PurchaseBillRefNo = internalId; purchasebill.Supplier = PendingGRNSelected[0].SupplierName; purchasebill.SupplierId = PendingGRNSelected[0].SupplierId; purchasebill.PurchaseBillDate = System.DateTime.Today; purchasebill.PurchaseBillDueDate = rep.GetBillDueDate(PendingGRNSelected[0].SupplierId).PurchaseBillDueDate; purchasebill.CurrencyId = new SupplierRepository().GetSupplierCurrency(PendingGRNSelected[0].SupplierId).CurrencyId; //purchasebill.CurrencyId = new CurrencyRepository().GetCurrencyFrmOrganization(OrganizationId).CurrencyId; return(View(purchasebill)); } catch (Exception) { TempData["error"] = "Some required data was missing. Please try again."; return(RedirectToAction("Index")); } }
public ActionResult Edit(PurchaseBill model) { ViewBag.Title = "Edit"; model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); FillAdditionDeduction(); FillCurrency(); var repo = new PurchaseBillRepository(); //var result1 = new PurchaseBillRepository().CHECK(model.SupplyOrderId); //if (result1 > 0) //{ // TempData["error"] = "Sorry!!..Already Used!!"; // TempData["PurchaseRequestNo"] = null; // return View("Edit", model); //} //else { try { //var result2 = new PurchaseBillRepository().DeletePuchaseBillDT(model.PurchaseBillId); //var result3 = new PurchaseBillRepository().DeletePuchaseBillHD(model.PurchaseBillId, UserID.ToString()); //string id = new PurchaseBillRepository().InsertPurchaseBill(model); int output = new PurchaseBillRepository().UpdatePurchaseBill(model); TempData["success"] = "Updated successfully. (" + model.PurchaseBillRefNo + ")"; TempData["error"] = ""; return(RedirectToAction("PurchaseBillList")); } 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(model)); } }
public ActionResult Save(PurchaseBill model) { try { if (ModelState.IsValid) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); string id = new PurchaseBillRepository().InsertPurchaseBill(model); if (id.Split('|')[0] != "0") { TempData["success"] = "Saved successfully. Purchase Bill Reference No. is " + id.Split('|')[1]; TempData["error"] = ""; return(RedirectToAction("Index")); } else { throw new Exception(); } } else { var allErrors = ModelState.Values.SelectMany(v => v.Errors); } } 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; } FillAdditionDeduction(); FillCurrency(); return(View("Create", model)); }
public ActionResult Edit(int id = 0) { try { if (id != 0) { PurchaseBill PurchaseBill = new PurchaseBill(); PurchaseBill = new PurchaseBillRepository().GetPurchaseBill(id); PurchaseBill.PurchaseBillAmount *= (decimal)1.00; PurchaseBill.SupplyOrderNo = new PurchaseBillRepository().PBSupplyOrderNos(id).SupplyOrderNo; PurchaseBill.Items = new PurchaseBillItemRepository().GetPurchaseBillItem(id); FillAdditionDeduction(); FillCurrency(); return(View(PurchaseBill)); } 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")); }