public ActionResult Delete(string MSerNo) { try { if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) { //Log.Error(ex + ex.StackTrace); TempData["SessionExipred"] = "true"; //TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "Login", null)); } UnitAMeeting queryCrit = new UnitAMeeting(); queryCrit.MSerialNo = int.Parse(MSerNo); MysqlDBA <UnitAMeeting> mysqlDBA = new MysqlDBA <UnitAMeeting>(FunctionController.CONNSTR); mysqlDBA.Delete(queryCrit); TempData["success"] = "OK"; TempData["parentreload"] = "OK"; } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "Function"; TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "MeetingAdd", null)); } return(RedirectToAction("Index", "MeetingAdd", null)); }
public ActionResult Index(int page = 1) { MeetingView viewObj = new MeetingView(); try { if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) { //Log.Error(ex + ex.StackTrace); TempData["SessionExipred"] = "true"; //TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "Login", null)); } UnitAMeeting queryCrit = new UnitAMeeting(); queryCrit.INSTNO = Session["INSTNO"].ToString(); queryCrit.MType = "1"; viewObj.meetingList = ((List <UnitAMeeting>) new MysqlDBA <UnitAMeeting>(FunctionController.CONNSTR).getDataListNoKey(queryCrit)).OrderBy(p => p.MSerialNo).ToPagedList(page, defaulPageSize); } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "Function"; TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "Meeting", null)); } return(View(viewObj)); }
public ActionResult Add(MeetingView data) { if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) { TempData["SessionExipred"] = "true"; return(RedirectToAction("Index", "Login", null)); } try { MysqlDBA <UnitAMeeting> mysqlDBA = new MysqlDBA <UnitAMeeting>(FunctionController.CONNSTR); UnitAMeeting alloc = new UnitAMeeting(); alloc.Year = data.year; alloc.INSTNO = Session["INSTNO"].ToString(); //-1代表新增,取新流水號 if (data.MSerial == "-1" || string.IsNullOrEmpty(data.MSerial)) { alloc.MSerialNo = Utility.Utility.getMeetingSerNo(mysqlDBA); alloc.MSerialNo++; } else { //不是-1表修改,帶原來流水號 alloc.MSerialNo = int.Parse(data.MSerial); } alloc.MType = "2"; string verifyDateResult = Utility.Utility.verifyDate(data.date); if (verifyDateResult == "DateError") { TempData["error"] = "日期格式錯誤,需為民國年/月月/日日 如:109/09/08"; return(RedirectToAction("Index", "CaseDiscussAdd", null)); } alloc.MDate = Utility.Utility.convertROC2UDTDateFormat(data.date); alloc.Topic = data.topic; alloc.ProfCnt = int.Parse(string.IsNullOrEmpty(data.profcnt) ? "0" : data.profcnt); alloc.AttendNum = int.Parse(string.IsNullOrEmpty(data.attend) ? "0" :data.attend); alloc.ModifyDate = DateTime.Now.ToString("yyyy-MM-dd"); alloc.CreateDate = DateTime.Parse(alloc.CreateDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : alloc.CreateDate).ToString("yyyy-MM-dd"); mysqlDBA.InsertOrUpdate(alloc); TempData["success"] = "OK"; TempData["parentreload"] = "OK"; //alloc } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "Function"; TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "CaseDiscussAdd", null)); } return(RedirectToAction("Index", "CaseDiscussAdd")); }
// GET: Meeting public ActionResult Edit(string MSerNo) { try { if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) { //Log.Error(ex + ex.StackTrace); TempData["SessionExipred"] = "true"; //TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "Login", null)); } List <UnitAMeeting> listData = new List <UnitAMeeting>(); UnitAMeeting queryCrit = new UnitAMeeting(); queryCrit.MSerialNo = int.Parse(MSerNo); MysqlDBA <UnitAMeeting> mysqlDBA = new MysqlDBA <UnitAMeeting>(FunctionController.CONNSTR); DataSet ds = mysqlDBA.getDataSet(string.Format("SELECT * FROM UnitAMeeting WHERE MSerialNo = '{0}'", queryCrit.MSerialNo)); foreach (DataRow row in ds.Tables[0].Rows) { UnitAMeeting data = new UnitAMeeting(); data.Year = row["Year"].ToString(); data.INSTNO = row["INSTNO"].ToString(); data.MSerialNo = int.Parse(row["MSerialNo"].ToString()); data.MType = row["MType"].ToString(); data.MDate = Utility.Utility.convertUDT2ROCDateFormat(DateTime.Parse(row["MDate"].ToString()).ToString("MM/dd/yyyy")); data.Topic = row["Topic"].ToString(); data.AttendNum = int.Parse(row["AttendNum"].ToString()); data.ProfCnt = int.Parse(row["ProfCnt"].ToString()); data.CreateDate = row["CreateDate"].ToString(); data.ModifyDate = row["ModifyDate"].ToString(); listData.Add(data); } TempData["UnitAMeeting"] = listData; } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "Function"; TempData["error"] = ex + ex.StackTrace; //tran.Rollback(); return(RedirectToAction("Index", "Meeting", null)); } return(RedirectToAction("Index", "MeetingAdd", null)); }