public ActionResult AddPlant(string Sys_Plant_name) { try { using (var db = new SAEntities()) { TM_SysPlant plant = new TM_SysPlant(); plant.Sys_Plant_name = Sys_Plant_name; plant.del_flag = false; plant.update_dt = DateTime.Now; plant.update_by = Session["SA_Auth"].ToString(); db.TM_SysPlant.Add(plant); db.SaveChanges(); } //var db = new PCREntities(); //PCR_Impact plant = new PCR_Impact(); //plant.imp_name = Sys_Plant_name; //db.PCR_Impact.Add(plant); return(Json(true)); } catch (Exception) { // Do some error logging stuff, handle exception, etc. return(Json(false)); } }
public JsonResult CreateUser() { try { var formData = Request.Form["Sys_User_id"]; var plant = byte.Parse(Request.Form["Sys_Plant_id"]); var dbData = dbSA.TM_SysUser.Where(w => w.Sys_User_id == formData && w.Sys_Plant_id == plant).FirstOrDefault(); if (dbData == null) { TM_SysUser data = new TM_SysUser(); data.Sys_User_id = formData; data.Sys_Plant_id = plant; data.Sys_GroupType_id = byte.Parse(Request.Form["Sys_GroupType_id"]); data.lv_id = 1; data.user_active = true; dbSA.TM_SysUser.Add(data); } else { dbData.user_active = true; } dbSA.SaveChanges(); return(Json(new { Result = "OK", Record = dbSA.TM_SysUser.FirstOrDefault() })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }