// GET: Supporting/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CR_Mas_Com_Supporting cR_Mas_Com_Supporting = db.CR_Mas_Com_Supporting.Find(id); if (cR_Mas_Com_Supporting == null) { return(HttpNotFound()); } else { if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "A" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Activated" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "1" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Undeleted") { ViewBag.stat = "حذف"; ViewBag.h = "تعطيل"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "D" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Deleted" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "0") { ViewBag.stat = "إسترجاع"; ViewBag.h = "تعطيل"; ViewData["ReadOnly"] = "true"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "H" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Hold" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "2") { ViewBag.h = "تنشيط"; ViewBag.stat = "حذف"; ViewData["ReadOnly"] = "true"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == null) { ViewBag.h = "تعطيل"; ViewBag.stat = "حذف"; } ViewBag.delete = cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status; ViewBag.CR_Mas_Com_Supporting_Type = new SelectList(db.CR_Mas_Com_Supporting, "CR_Mas_Com_Supporting_Type", "CR_Mas_Com_Supporting_Type"); } return(View(cR_Mas_Com_Supporting)); }
// GET: Supporting/Create public ActionResult Create() { var TypeList = new SelectList(new[] { new { ID = "1", Name = "شركات المساندة" }, new{ ID = "2", Name = "شركات التأمين" }, new{ ID = "3", Name = "البنوك" }, }, "ID", "Name", 1); ViewData["list"] = TypeList; ViewBag.CR_Mas_Com_Supporting_Type = new SelectList(db.CR_Mas_Com_Supporting, "CR_Mas_Com_Supporting_Type", "CR_Mas_Com_Supporting_Type"); CR_Mas_Com_Supporting sup = new CR_Mas_Com_Supporting(); sup = GetLastRecord(); sup.CR_Mas_Com_Supporting_Status = "A"; return(View(sup)); }
//////// GET: Supporting/Details/5 //////public ActionResult Details(string id) //////{ ////// if (id == null) ////// { ////// return new HttpStatusCodeResult(HttpStatusCode.BadRequest); ////// } ////// CR_Mas_Com_Supporting cR_Mas_Com_Supporting = db.CR_Mas_Com_Supporting.Find(id); ////// if (cR_Mas_Com_Supporting == null) ////// { ////// return HttpNotFound(); ////// } ////// return View(cR_Mas_Com_Supporting); //////} public CR_Mas_Com_Supporting GetLastRecord() { var Lrecord = db.CR_Mas_Com_Supporting.Max(Lr => Lr.CR_Mas_Com_Supporting_Code); CR_Mas_Com_Supporting s = new CR_Mas_Com_Supporting(); if (Lrecord != null) { int val = int.Parse(Lrecord) + 1; s.CR_Mas_Com_Supporting_Code = val.ToString(); } else { s.CR_Mas_Com_Supporting_Code = "1001"; } return(s); }
public ActionResult Edit([Bind(Include = "CR_Mas_Com_Supporting_Code, CR_Mas_Com_Supporting_Type, CR_Mas_Com_Supporting_Ar_Long_Name, " + "CR_Mas_Com_Supporting_Ar_Short_Name, CR_Mas_Com_Supporting_En_Long_Name,CR_Mas_Com_Supporting_En_Short_Name, CR_Mas_Com_Supporting_Tax_Number," + " CR_Mas_Com_Supporting_Status, CR_Mas_Com_Supporting_Reasons")] CR_Mas_Com_Supporting cR_Mas_Com_Supporting, string save, string delete, string hold) { if (!string.IsNullOrEmpty(save)) { if (ModelState.IsValid) { var LrecordExitArabeLng = db.CR_Mas_Com_Supporting.Any(f => f.CR_Mas_Com_Supporting_Code != cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Code && f.CR_Mas_Com_Supporting_Ar_Long_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name); var LrecordExitArabeSh = db.CR_Mas_Com_Supporting.Any(f => f.CR_Mas_Com_Supporting_Code != cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Code && f.CR_Mas_Com_Supporting_Ar_Short_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name); var LrecordExitEnglishLng = db.CR_Mas_Com_Supporting.Any(f => f.CR_Mas_Com_Supporting_Code != cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Code && f.CR_Mas_Com_Supporting_En_Long_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name); var LrecordExitEnglishSh = db.CR_Mas_Com_Supporting.Any(f => f.CR_Mas_Com_Supporting_Code != cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Code && f.CR_Mas_Com_Supporting_En_Short_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name); if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name.Length >= 3 && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name.Length >= 3 && !LrecordExitArabeLng && !LrecordExitArabeSh && !LrecordExitEnglishLng && !LrecordExitEnglishSh) { db.Entry(cR_Mas_Com_Supporting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name == null) { ViewBag.LRExistAr = "الرجاء إدخال بيانات الحقل"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name == null) { ViewBag.LRExistEn = "الرجاء إدخال بيانات الحقل"; } if (LrecordExitArabeLng) { ViewBag.LRExistArLng = "عفوا هذه الشركة موجودة"; } if (LrecordExitArabeSh) { ViewBag.LRExistArSh = "عفوا هذه الشركة موجودة"; } if (LrecordExitEnglishLng) { ViewBag.LRExistEnLng = "عفوا هذه الشركة موجودة"; } if (LrecordExitEnglishSh) { ViewBag.LRExistEnSh = "عفوا هذه الشركة موجودة"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name.Length < 3) { ViewBag.LRExistAr = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name.Length < 3) { ViewBag.LRExistAr = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name.Length < 3) { ViewBag.LRExistEn = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name.Length < 3) { ViewBag.LRExistEn = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } } } } if (delete == "Delete" || delete == "حذف") { cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status = "D"; db.Entry(cR_Mas_Com_Supporting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (delete == "Activate" || delete == "إسترجاع") { cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status = "A"; db.Entry(cR_Mas_Com_Supporting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (hold == "تعطيل" || hold == "hold") { cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status = "H"; db.Entry(cR_Mas_Com_Supporting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (hold == "تنشيط" || hold == "Activate") { cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status = "A"; db.Entry(cR_Mas_Com_Supporting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "A" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Activated" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "1" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Undeleted") { ViewBag.stat = "حذف"; ViewBag.h = "تعطيل"; } if ((cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "D" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Deleted" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "0")) { ViewBag.stat = "إسترجاع"; ViewBag.h = "تعطيل"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "H" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "Hold" || cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == "2") { ViewBag.h = "تنشيط"; ViewBag.stat = "حذف"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status == null) { ViewBag.h = "تعطيل"; ViewBag.stat = "حذف"; } ViewBag.delete = cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status; ViewBag.CR_Mas_Com_Supporting_Type = new SelectList(db.CR_Mas_Com_Supporting, "CR_Mas_Com_Supporting_Type", "CR_Mas_Com_Supporting_Type"); return(View(cR_Mas_Com_Supporting)); }
public ActionResult Create([Bind(Include = "CR_Mas_Com_Supporting_Code, CR_Mas_Com_Supporting_Type, CR_Mas_Com_Supporting_Ar_Long_Name, " + "CR_Mas_Com_Supporting_Ar_Short_Name, CR_Mas_Com_Supporting_En_Long_Name,CR_Mas_Com_Supporting_En_Short_Name, CR_Mas_Com_Supporting_Tax_Number," + " CR_Mas_Com_Supporting_Status, CR_Mas_Com_Supporting_Reasons")] CR_Mas_Com_Supporting cR_Mas_Com_Supporting) { try { if (ModelState.IsValid) { var LrecordExitArabeLng = db.CR_Mas_Com_Supporting.Any(Lr => Lr.CR_Mas_Com_Supporting_Ar_Long_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name); var LrecordExitArabeSh = db.CR_Mas_Com_Supporting.Any(Lr => Lr.CR_Mas_Com_Supporting_Ar_Short_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name); var LrecordExitEnglishLng = db.CR_Mas_Com_Supporting.Any(Lr => Lr.CR_Mas_Com_Supporting_En_Long_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name); var LrecordExitEnglishSh = db.CR_Mas_Com_Supporting.Any(Lr => Lr.CR_Mas_Com_Supporting_En_Short_Name == cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name); if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name != null && !LrecordExitArabeLng && !LrecordExitArabeSh && !LrecordExitEnglishLng && !LrecordExitEnglishSh && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name.Length >= 3 && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name.Length >= 3 && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name.Length >= 3 && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name.Length >= 3) { cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Code = GetLastRecord().CR_Mas_Com_Supporting_Code; db.CR_Mas_Com_Supporting.Add(cR_Mas_Com_Supporting); db.SaveChanges(); cR_Mas_Com_Supporting = new CR_Mas_Com_Supporting(); cR_Mas_Com_Supporting = GetLastRecord(); cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Status = "A"; TempData["TempModel"] = "تم الحفظ بنجاح"; return(RedirectToAction("Create", "Supporting")); } else { if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name == null) { ViewBag.LRExistAr = "الرجاء إدخال بيانات الحقل"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name == null) { ViewBag.LRExistEn = "الرجاء إدخال بيانات الحقل"; } if (LrecordExitArabeLng) { ViewBag.LRExistArLng = "عفوا هذه الشركة موجودة"; } if (LrecordExitArabeSh) { ViewBag.LRExistArSh = "عفوا هذه الشركة موجودة"; } if (LrecordExitEnglishLng) { ViewBag.LRExistEn = "عفوا هذه الشركة موجودة"; } if (LrecordExitEnglishSh) { ViewBag.LRExistEn = "عفوا هذه الشركة موجودة"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Long_Name.Length < 3) { ViewBag.LRExistAr = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_Ar_Short_Name.Length < 3) { ViewBag.LRExistAr = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Long_Name.Length < 3) { ViewBag.LRExistEn = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } if (cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name != null && cR_Mas_Com_Supporting.CR_Mas_Com_Supporting_En_Short_Name.Length < 3) { ViewBag.LRExistEn = "عفوا الاسم يحتوي على ما بين 3 و 30 حرفًا"; } } } } catch (Exception) { } ViewBag.CR_Mas_Com_Supporting_Type = new SelectList(db.CR_Mas_Com_Supporting, "CR_Mas_Com_Supporting_Type", "CR_Mas_Com_Supporting_Type"); return(View(cR_Mas_Com_Supporting)); }