// 後台會員修改畫面 public ActionResult MemberEdit(string appSer) { // 1. 取得Get 參數, app_Ser System.Diagnostics.Debug.WriteLine(" >>>> ProEdit AppSer: " + appSer); // 2. 於資料庫搜尋此筆資料 //----> 程式碼 Models.ShopCarDatasetTableAdapters.MemberTableAdapter memadp = new Models.ShopCarDatasetTableAdapters.MemberTableAdapter(); DataTable dt; dt = memadp.GetOneMemberData(Convert.ToInt32(appSer)); DataRow drow = dt.Rows[0]; //male 性別直接以男/女表示 var memItem = new { appSer = wf.tos(drow["app_ser"]), user_id = wf.tos(drow["user_id"]), user_name = wf.tos(drow["user_name"]), user_password = wf.tos(drow["user_password"]), birthDay = wf.tos(((DateTime)drow["BirthDay"]).ToString("yyyy/MM/dd")), male = wf.tos(drow["male"]), mobile = wf.tos(drow["mobile"]), tel = wf.tos(drow["tel"]), extno = wf.tos(drow["extno"]), address = wf.tos(drow["Address"]), email = wf.tos(drow["email"]) }; return Json(memItem, JsonRequestBehavior.AllowGet); //return View("MemberEdit", memItem); }
public ActionResult MemberDelete(FormCollection formCollection) { System.Diagnostics.Debug.WriteLine(" >>>> ProDelete -------------------------->>>> "); System.Diagnostics.Debug.WriteLine(" >>>> ProAdd proNo: " + formCollection["appSer"]); Int32 appser = Convert.ToInt32(formCollection["appSer"]); // 2. 刪除該appser產品 //----> 程式碼 Models.ShopCarDatasetTableAdapters.MemberTableAdapter memadp = new Models.ShopCarDatasetTableAdapters.MemberTableAdapter(); memadp.DeleteMemberData(appser); // 3. Return pro_list return RedirectToAction("MemberList"); }
// // GET: /Member/ public ActionResult MemberToJsonData() { Models.ShopCarDatasetTableAdapters.MemberTableAdapter memadp = new Models.ShopCarDatasetTableAdapters.MemberTableAdapter(); DataTable dt = memadp.GetData(); Hashtable myHT = new Hashtable(); myHT.Add("memberItem", dt); string obj_json = JsonConvert.SerializeObject(myHT); return Content(obj_json, "application/json"); }
public ActionResult MemberUpdate(FormCollection formCollection) { // 1. 取得前端 form 的欄位資料 // 2. 更新產品資料表 //----> 程式碼 Nullable<DateTime> BirthDay; if (formCollection["BirthDay"] == "") { BirthDay = null; } else { BirthDay = Convert.ToDateTime(formCollection["BirthDay"]); } Models.ShopCarDatasetTableAdapters.MemberTableAdapter memadp = new Models.ShopCarDatasetTableAdapters.MemberTableAdapter(); memadp.UpdateMemberData(formCollection["user_id"], formCollection["user_name"], formCollection["user_password"], BirthDay, formCollection["male"], formCollection["mobile"], formCollection["tel"], formCollection["extno"], formCollection["Address"], formCollection["email"], Convert.ToInt32(formCollection["app_ser"])); /* var memItem = new { appSer = formCollection["app_ser"], user_id = formCollection["user_id"], user_name = formCollection["user_name"], user_password = formCollection["user_password"], BirthDay = formCollection["BirthDay"], male = formCollection["male"], mobile = formCollection["mobile"], tel = formCollection["tel"], extno = formCollection["extno"], Address = formCollection["Address"], email = formCollection["email"] }; */ // return View("MemberEdit", memItem); return RedirectToAction("MemberList"); }
public ActionResult MemberCreate(FormCollection formCollection) { System.Diagnostics.Debug.WriteLine(" >>>> MemberEdit -------------------------->>>> "); System.Diagnostics.Debug.WriteLine(" >>>> user_id: " + formCollection["user_id"]); System.Diagnostics.Debug.WriteLine(" >>>> user_password: "******"user_password"]); System.Diagnostics.Debug.WriteLine(" >>>> db null: " + Convert.IsDBNull(formCollection["user_password"])); System.Diagnostics.Debug.WriteLine(" >>>> user_name: " + formCollection["user_name"]); System.Diagnostics.Debug.WriteLine(" >>>> male: " + formCollection["male"]); System.Diagnostics.Debug.WriteLine(" >>>> BirthDay: " + formCollection["BirthDay"]); System.Diagnostics.Debug.WriteLine(" >>>> tel: " + formCollection["tel"]); System.Diagnostics.Debug.WriteLine(" >>>> extno: " + formCollection["extno"]); System.Diagnostics.Debug.WriteLine(" >>>> mobile: " + formCollection["mobile"]); System.Diagnostics.Debug.WriteLine(" >>>> email: " + formCollection["email"]); System.Diagnostics.Debug.WriteLine(" >>>> Address: " + formCollection["Address"]); if(wf.tos(formCollection["user_id"]) == "" || wf.tos(formCollection["user_password"]) == ""){ // 非法進入此 action 重導到新增會員畫面 return RedirectToAction("MemberAdd"); }else{ // 將會員資料寫入資料庫 Models.ShopCarDatasetTableAdapters.MemberTableAdapter memadp = new Models.ShopCarDatasetTableAdapters.MemberTableAdapter(); int ret_app_ser; string ps_decode = ""; if (Convert.IsDBNull(formCollection["password"]) == false) { ps_decode = wf.base64Decode(formCollection["user_password"]); } ret_app_ser = Convert.ToInt32(memadp.InsertMemberData(formCollection["user_id"], formCollection["user_name"], ps_decode , Convert.ToDateTime(formCollection["BirthDay"]), formCollection["male"], formCollection["mobile"], formCollection["tel"], formCollection["extno"], formCollection["Address"], formCollection["email"])); // 寫入成功後到新增成功畫面 return RedirectToAction("MemberCreateSuccess"); } }