public ActionResult Create(Tally_Sheet tally_sheet) { if (ModelState.IsValid) { var is_cargomanifest_code_exist = from t in db.Tally_Sheet where t.tally_sheet_code == tally_sheet.tally_sheet_code select t; var is_ship_arrival_exist = from t in db.Tally_Sheet where t.ship_arrival_id == tally_sheet.ship_arrival_id select t; if (is_cargomanifest_code_exist.Count() > 0) { TempData["errorMessage"] = "Cargo Manifest Code Already Exists, Please Enter Another One"; return RedirectToAction("Index"); } else if (is_ship_arrival_exist.Count() > 0) { TempData["errorMessage"] = "Only One Cargo Manifest Allowed For a Shipp Arrival, Please Choose Another One"; return RedirectToAction("Index"); } else { tally_sheet.employee_id = Convert.ToInt32(Session["id"]); db.Tally_Sheet.Add(tally_sheet); db.SaveChanges(); TempData["errorMessage"] = "Cargo Manifest Added Successfully"; return RedirectToAction("Index"); } } return RedirectToAction("Index"); }
public ActionResult Create(Tally_Sheet tally_sheet) { if (Session["login_status"] != null) { int[] z = (int[])Session["function_id"]; if (z.Contains(12)) { if (ModelState.IsValid) { var is_cargomanifest_code_exist = from t in db.Tally_Sheet where t.tally_sheet_code == tally_sheet.tally_sheet_code select t; var is_ship_arrival_exist = from t in db.Tally_Sheet where t.ship_arrival_id == tally_sheet.ship_arrival_id select t; if (is_cargomanifest_code_exist.Count() > 0) { TempData["errorMessage"] = "Cargo Manifest Code Already Exists, Please Enter Another One"; return RedirectToAction("Index"); } else if (is_ship_arrival_exist.Count() > 0) { TempData["errorMessage"] = "Only One Cargo Manifest Allowed For a Shipp Arrival, Please Choose Another One"; return RedirectToAction("Index"); } else { tally_sheet.employee_id = Convert.ToInt32(Session["id"]); tally_sheet.tally_sheet_code = "CM_"; db.Tally_Sheet.Add(tally_sheet); db.SaveChanges(); if (tally_sheet.tally_sheet_id < 10) { tally_sheet.tally_sheet_code = tally_sheet.tally_sheet_code + tally_sheet.tally_sheet_id.ToString("00"); } else { tally_sheet.tally_sheet_code = tally_sheet.tally_sheet_code + tally_sheet.tally_sheet_id; } db.Entry(tally_sheet).State = EntityState.Modified; db.SaveChanges(); TempData["errorMessage"] = "Cargo Manifest Added Successfully"; return RedirectToAction("Index"); } } return RedirectToAction("Index"); } else { return RedirectToAction("../Home/Dashboard"); } } else { return RedirectToAction("../Home"); } }
public ActionResult SaveFile(Tally_Sheet tally_sheet) { var tally_sheet_id_hd = Request.Form["tally_sheet_id_hd"].ToString(); var tally_sheet_id = Convert.ToInt32(Request.Form["tally_sheet_id_hd"]); db.Update_Tally_Sheet_Details(tally_sheet_id); //int updated_file_count = 0; HttpPostedFileBase file = Request.Files.Get("exchangefile"); var files = Request.Files["exchangefile"]; if (files != null) { FileInfo fil = new FileInfo(files.FileName); var filename = DateTime.Now.Ticks + fil.Extension; string path = Server.MapPath("~/Images/" + filename); files.SaveAs(path); SaveExcel(path, tally_sheet_id_hd); System.IO.File.Delete(path); db.SaveChanges(); } TempData["errorMessage"] = " Data Updated Successfully"; return RedirectToAction("Index", "Manage_Tally_Sheet"); }
public ActionResult DbSearchresult(Tally_Sheet tally_sheet) { //Queue q = new Queue(); if (tally_sheet.ship_arrival_id != 0 && tally_sheet.tally_sheet_code != null) { var result = (from t in db.Tally_Sheet join sa in db.Ship_Arrival on t.ship_arrival_id equals sa.ship_arrival_id where t.ship_arrival_id == tally_sheet.ship_arrival_id && t.tally_sheet_code == tally_sheet.tally_sheet_code select new Tally_SheetModel { tally_sheet_code = t.tally_sheet_code, ship_arrival_code = sa.ship_arrival_code, tally_sheet_id = t.tally_sheet_id }).Distinct(); return View("Index", result.ToList()); } else if (tally_sheet.ship_arrival_id != 0 && tally_sheet.tally_sheet_code == null) { var result = (from t in db.Tally_Sheet join sa in db.Ship_Arrival on t.ship_arrival_id equals sa.ship_arrival_id where t.ship_arrival_id == tally_sheet.ship_arrival_id select new Tally_SheetModel { tally_sheet_code = t.tally_sheet_code, ship_arrival_code = sa.ship_arrival_code, tally_sheet_id = t.tally_sheet_id }).Distinct(); return View("Index", result.ToList()); } else if (tally_sheet.ship_arrival_id == 0 && tally_sheet.tally_sheet_code != null) { var result = (from t in db.Tally_Sheet join sa in db.Ship_Arrival on t.ship_arrival_id equals sa.ship_arrival_id where t.tally_sheet_code == tally_sheet.tally_sheet_code select new Tally_SheetModel { tally_sheet_code = t.tally_sheet_code, ship_arrival_code = sa.ship_arrival_code, tally_sheet_id = t.tally_sheet_id }).Distinct(); return View("Index", result.ToList()); } return RedirectToAction("Index"); }