public static string new主題類型編號() { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t主題類型 orderby t.f主題編號 descending select t.f主題編號).FirstOrDefault(); int int_主題類型尾碼 = 0; if (int.TryParse(q.Substring(3), out int_主題類型尾碼)) { int_主題類型尾碼 = int.Parse(q.Substring(3)) + 1; } if (int.TryParse(q.Substring(2, 2), out int_主題類型尾碼)) { int_主題類型尾碼 = int.Parse(q.Substring(2, 2)) + 1; } if (int_主題類型尾碼 < 10) { return("PE" + "0" + int_主題類型尾碼); } else { return("PE" + int_主題類型尾碼); } } catch { return("PE01"); } }
public static string new文章編號(string str_主題編號) { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t論壇文章資料表 where t.f文章編號.Contains(str_主題編號) orderby t.f文章編號 descending select t.f文章編號).FirstOrDefault(); int int_文章編碼 = 0; if (int.TryParse(q.Substring(7), out int_文章編碼)) { int_文章編碼 = int.Parse(q.Substring(7)) + 1; } if (int.TryParse(q.Substring(6, 2), out int_文章編碼)) { int_文章編碼 = int.Parse(q.Substring(6, 2)) + 1; } if (int_文章編碼 < 10) { return("AT" + str_主題編號 + "0" + int_文章編碼); } else { return("AT" + str_主題編號 + int_文章編碼); } } catch { return("AT" + str_主題編號 + "01"); } }
public static string new活動票券編號(string str_活動場次編號) { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t活動票券 where t.f票券編號.Contains(str_活動場次編號) orderby t.f票券編號 descending select t.f票券編號).FirstOrDefault(); int int_活動票券編碼 = 0; if (int.TryParse(q.Substring(23), out int_活動票券編碼)) { int_活動票券編碼 = int.Parse(q.Substring(23)) + 1; } if (int.TryParse(q.Substring(22, 2), out int_活動票券編碼)) { int_活動票券編碼 = int.Parse(q.Substring(22, 2)) + 1; } if (int_活動票券編碼 < 10) { return(str_活動場次編號 + "TK0" + int_活動票券編碼); } else { return(str_活動場次編號 + "TK" + int_活動票券編碼); } } catch { return(str_活動場次編號 + "TK01"); } }
public static string new票券訂單編號() { dbEventFunEntities db = new dbEventFunEntities(); string str_票券訂單前10碼 = "TO" + DateTime.Now.ToString("yyyyMMdd"); try { var q = (from t in db.t票券訂單 where t.f票券訂單編號.Contains(str_票券訂單前10碼) orderby t.f票券訂單編號 descending select t.f票券訂單編號).FirstOrDefault(); int int_票券訂單編碼 = 0; if (int.TryParse(q.Substring(11), out int_票券訂單編碼)) { int_票券訂單編碼 = int.Parse(q.Substring(11)) + 1; } if (int.TryParse(q.Substring(10, 2), out int_票券訂單編碼)) { int_票券訂單編碼 = int.Parse(q.Substring(10, 2)) + 1; } if (int_票券訂單編碼 < 10) { return("TO" + DateTime.Now.ToString("yyyyMMdd") + "0" + int_票券訂單編碼); } else { return("TO" + DateTime.Now.ToString("yyyyMMdd") + int_票券訂單編碼); } } catch { return("TO" + DateTime.Now.ToString("yyyyMMdd") + "01"); } }
//管理員個人編輯畫面 public ActionResult _AdminEditPartial() { dbEventFunEntities db = new dbEventFunEntities(); var adminid = (Session[CDictionary.Manager] as t管理者資料表).f管理者編號; var t = (from ad in db.t管理者資料表 where ad.f管理者編號 == adminid select ad).FirstOrDefault(); return(PartialView("_AdminEditPartial", t)); }
public static int new留言編號() { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t論壇文章留言 orderby t.f留言編號 descending select t.f留言編號).FirstOrDefault(); return(q + 1); } catch { return(1); } }
public static int new喜愛活動編號() { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t會員喜愛活動 orderby t.f喜愛活動流水號 descending select t.f喜愛活動流水號).FirstOrDefault(); return(q + 1); } catch { return(1); } }
//管理員個人資料 public ActionResult _AdminIndexPartial() { dbEventFunEntities db = new dbEventFunEntities(); if (Session[CDictionary.Manager] == null) { return(RedirectToAction("Login")); } int managerID = (Session[CDictionary.Manager] as t管理者資料表).f管理者編號; var manager = (from m in db.t管理者資料表 where m.f管理者編號 == managerID select m).FirstOrDefault(); return(PartialView("_AdminIndexPartial", manager)); }
public static string new企業會員編號() { dbEventFunEntities db = new dbEventFunEntities(); string str_會員前9碼 = "C" + DateTime.Now.ToString("yyyyMMdd"); try { var q = (from t in db.t企業會員 where t.f企業編號.Contains(str_會員前9碼) orderby t.f企業編號 descending select t.f企業編號).FirstOrDefault(); int int_會員編碼 = 0; if (int.TryParse(q.Substring(11), out int_會員編碼)) { int_會員編碼 = int.Parse(q.Substring(11)) + 1; } if (int.TryParse(q.Substring(10, 2), out int_會員編碼)) { int_會員編碼 = int.Parse(q.Substring(10, 2)) + 1; } if (int.TryParse(q.Substring(9, 3), out int_會員編碼)) { int_會員編碼 = int.Parse(q.Substring(9, 3)) + 1; } if (int_會員編碼 < 10) { return("C" + DateTime.Now.ToString("yyyyMMdd") + "00" + int_會員編碼); } if (int_會員編碼 < 100) { return("C" + DateTime.Now.ToString("yyyyMMdd") + "0" + int_會員編碼); } else { return("C" + DateTime.Now.ToString("yyyyMMdd") + int_會員編碼); } } catch { return("C" + DateTime.Now.ToString("yyyyMMdd") + "001"); } }
public ActionResult _AdminSavePartial(t管理者資料表 ad) { dbEventFunEntities db = new dbEventFunEntities(); //判斷是否有圖片 if (ad.photo != null) { var pathPhoto = Path.Combine(Server.MapPath("/Content/images/admin/"), ad.f管理者編號 + ".jpg"); ad.photo.SaveAs(pathPhoto); } if (ModelState.IsValid) { ad.f個人照片 = ad.f管理者編號.ToString() + ".jpg"; ad.f上次登入時間 = DateTime.Now; db.Entry(ad).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AdminIndex")); } return(RedirectToAction("AdminIndex")); }
public static string new活動日期編號(string str_活動編號) { dbEventFunEntities db = new dbEventFunEntities(); try { var q = (from t in db.t活動日期 where t.f活動日期編號.Contains(str_活動編號) orderby t.f活動日期編號 descending select t.f活動日期編號).FirstOrDefault(); int int_活動日期編碼 = 0; if (int.TryParse(q.Substring(15), out int_活動日期編碼)) { int_活動日期編碼 = int.Parse(q.Substring(15)) + 1; } if (int.TryParse(q.Substring(14, 2), out int_活動日期編碼)) { int_活動日期編碼 = int.Parse(q.Substring(14, 2)) + 1; } if (int.TryParse(q.Substring(13, 3), out int_活動日期編碼)) { int_活動日期編碼 = int.Parse(q.Substring(13, 3)) + 1; } if (int_活動日期編碼 < 10) { return(str_活動編號 + "D00" + int_活動日期編碼); } if (int_活動日期編碼 < 100) { return(str_活動編號 + "D0" + int_活動日期編碼); } else { return(str_活動編號 + "D" + int_活動日期編碼); } } catch { return(str_活動編號 + "D001"); } }
public ActionResult CreateImages(t活動圖片 t活動圖片) {//[Bind(Include = "f圖片編號,f活動編號,f活動圖片")] if (ModelState.IsValid) { string fileName = Path.GetFileName(t活動圖片.photo.FileName); // string fileName = methodNewID.new活動圖片編號().ToString(); var pathPhoto = Path.Combine(Server.MapPath("~/Content/images/activity"), t活動圖片.f活動編號 + ".jpg"); t活動圖片.photo.SaveAs(pathPhoto); t活動圖片.f圖片編號 = methodNewID.new活動圖片編號(); dbEventFunEntities db = new dbEventFunEntities(); t活動圖片.f活動圖片 = "/Content/images/activity/" + t活動圖片.f活動編號 + ".jpg"; db.t活動圖片.Add(t活動圖片); db.SaveChanges(); return(RedirectToAction("AddEventOK")); } ViewBag.f活動編號 = new SelectList(db.t活動, "f活動編號", "f次主題編號", t活動圖片.f活動編號); return(View("CreateImages")); }