public ActionResult PostalDispatch() { List <PostalDispatch> CategoryList = new List <PostalDispatch>(); Property p = new Property(); DataSet ds = new DataSet(); p.OnTable = "FetchPostalDispatch"; ds = dl.FetchPostalDispatch_sp(p); try { foreach (DataRow item in ds.Tables[0].Rows) { PostalDispatch m = new PostalDispatch(); m.Id = item["Id"].ToString(); m.FromTitle = item["FromTitle"].ToString(); m.ReferenceNo = item["ReferenceNo"].ToString(); m.ToTitle = item["ToTitle"].ToString(); m.Date = item["Date"].ToString(); m.Address = item["Address"].ToString(); m.Note = item["Note"].ToString(); m.Attachment = item["Attachment"].ToString(); m.AddedBy = item["AddedBy"].ToString(); m.IsActive = item["IsActive"].ToString(); CategoryList.Add(m); } ViewBag.CategoryList = CategoryList; } catch (Exception e) { } return(View()); }
public ActionResult PostalDispatch(PostalDispatch c, List <HttpPostedFileBase> Attachment) { HttpCookie rxgoAdminCookie = Request.Cookies["rxgoAdmin"]; string AddedBy = rxgoAdminCookie.Values["Hid"]; c.AddedBy = AddedBy; //string no = "BR" + System.DateTime.Now.Year + 1; string fileLocation = ""; string ItemUploadFolderPath = "~/DataImages/"; try { try { if (Attachment.Count > 0) { foreach (HttpPostedFileBase file in Attachment) { try { if (file.ContentLength == 0) { continue; } if (file.ContentLength > 0) { fileLocation = HelperFunctions.renameUploadFile(file, ItemUploadFolderPath); if (fileLocation == "") { fileLocation = ""; } } } catch (Exception ex) { } if (fileLocation == "" || fileLocation == null) { c.Attachment = c.Attachment; } else { c.Attachment = fileLocation; } } } } catch (Exception ex) { } } catch (Exception ex) { } try { if (dl.InsertPostalDispatch_Sp(c) > 0) { TempData["MSG"] = "Postal Dispatch Added Successfully"; } } catch (Exception ex) { TempData["MSG"] = "Something went wrong."; return(Redirect("/FrontOffice/PostalDispatch")); } TempData["MSG"] = "Postal Dispatch Added Successfully."; return(Redirect("/FrontOffice/PostalDispatch")); }