public static string SaveUserLog(string strConnection, int actSerial, int sysUserId, LogActType actType, string funcId, object actIp, string userId) { SqlParameter[] param = { new SqlParameter("actSerial", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actSerial), new SqlParameter("sysUserId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, sysUserId), new SqlParameter("actType", SqlDbType.TinyInt, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actType), new SqlParameter("funcId", SqlDbType.Char, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (funcId == null || funcId.ToString().Trim() == "" ? "": (object)funcId)), new SqlParameter("actIp", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, (actIp == null || actIp.ToString().Trim() == "" ? "": actIp)), new SqlParameter("userId", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userId), }; string strSql = "insert into S90_userLog (actSerial,sysUserId,actType,funcId,actIp,userId,actTime) values (@actSerial,@sysUserId,@actType,@funcId,@actIp,@userId,getdate())"; string errStr = SqlTool.ExecuteNonQuery(strConnection, strSql.ToString(), param); if (errStr != "") { return(errStr); } else { return(""); } }
public ActionResult checkQuesWriteDate() { JObject jo = new JObject(); try { string errStr = ""; ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); if (userData.sysUserId.ToString() != "-1" && userData.sysUserId.ToString() != "-2") { string strSql = "select t1.qId, t2.eDate from Q30_questionMaster t1 left join Q30_questionDate t2 on t2.qId=t1.qId and t2.eDate <> '' where t1.statusx='10' and t1.creatUser='******' "; DataTable tbl_QueryData1 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData1"); if (tbl_QueryData1.Rows.Count > 0) { for (int i = 0; i < tbl_QueryData1.Rows.Count; i++) { if (DateTime.Parse(tbl_QueryData1.Rows[i]["eDate"].ToString()).AddDays(1) < DateTime.Now) { strSql = "upDate Q30_answer set statusx='20' where qId='" + tbl_QueryData1.Rows[i]["qId"].ToString() + "' and statusx='10' "; errStr = SqlTool.ExecuteNonQuery(strSql.ToString()); if (errStr != "") { throw new Exception(errStr); } } } } } jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo.Add("status", "error"); jo.Add("error", ex.Message.ToString()); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.Q00010 actRow) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { #region ACall_checkIsDBNull actRow.qId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.qId); actRow.objectIds = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.objectIds); #endregion #region 先刪除目前的該問卷的對象 strSql.Clear(); strSql.Append("delete from Q30_questionObjects where qId='" + actRow.qId.ToString() + "' "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString()); if (errStr != "") { throw new Exception(errStr); } #endregion #region 將目前選擇好的對象存入資料表中 string[] sysObjectId = actRow.objectIds.ToString().Split(','); for (int i = 0; i < sysObjectId.Length; i++) { if (sysObjectId[i] == "") { continue; } #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId), new SqlParameter("sysObjectId", SqlDbType.Int, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, sysObjectId[i]), new SqlParameter("creatUser", SqlDbType.Int, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("actUser", SqlDbType.Int, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_questionObjects (qId, sysObjectId, creatUser) values (@qId, @sysObjectId, @creatUser) "); strSql.Append("UpDate Q30_questionMaster set actUser=@actUser, actTime=getDate() where qId=@qId "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } } actRow.actUser = userData.userName; actRow.actTime = DateTime.Now; #region OperLog 修改問卷填寫對象 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "M"; operLogRow["qId"] = actRow.qId.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_questionObjects", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion if (errStr == "") { JArray ja = new JArray(); var itemObject = new JObject(); itemObject.Add("qId", actRow.qId.ToString()); itemObject.Add("actUser", actRow.actUser.ToString()); itemObject.Add("actTime", actRow.actTime.ToString()); ja.Add(itemObject); jo = new JObject(); jo.Add("status", "OK"); jo.Add("row", ja); } else { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", errStr); } return(Content(JsonConvert.SerializeObject(jo), "application/json")); #endregion } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSubmit(string qId) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo = new JObject(); try { strSql.Clear(); strSql.Append("select seq from Q30_answer where qId='" + qId + "' and creatUser='******' group by seq "); DataTable tbl_QueryData1 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData1"); if (tbl_QueryData1.Rows.Count == 0) { errStr = "請先儲存填寫內容,再進行繳交。"; if (errStr != "") { throw new Exception(errStr); } } #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param2 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, qId), new SqlParameter("seq", SqlDbType.Int, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, tbl_QueryData1.Rows[0]["seq"].ToString()) }; #endregion strSql.Clear(); strSql.Append(" Update Q30_answer set statusx='20' where qId='" + qId + "' and creatUser='******' "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param2); if (errStr != "") { throw new Exception(errStr); } #region OperLog 繳交問卷 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); tbl_operLog1.Columns.Add("seq", typeof(string)); tbl_operLog1.Columns.Add("creatUser", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = 9; operLogRow["actStatus"] = "P"; operLogRow["qId"] = qId; operLogRow["seq"] = tbl_QueryData1.Rows[0]["seq"].ToString(); operLogRow["creatUser"] = "******"; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_answer", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion jo = new JObject(); jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.W00016_act actRow, string qNbr) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; string seq = ""; try { DateTime dt = DateTime.Now; if (actRow.arrAns != null) { #region 判斷目前為第幾位填答人數 seq = actRow.seq.ToString(); #endregion foreach (Models.question.W00016_act_d arrAn in actRow.arrAns) { arrAn.answer = ZhConfig.ZhIniObj.ACall_checkIsDBNull(arrAn.answer); if (arrAn.topicType.ToString() == "cb" && arrAn.answer.ToString() != null && arrAn.answer.ToString() != "") { arrAn.answer = arrAn.answer.ToString().Substring(0, arrAn.answer.ToString().Length - 1); } if (arrAn.topicType.ToString() == "lb") { arrAn.answer = ""; } //DataTable tbl_answerId = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, " select answerId from Q30_answer where qId='" + actRow.qId.ToString() + "' and creatUser='******' and answerId='"+qNbr+"' ", "tbl_answerId"); //if (tbl_answerId.Rows[0][0].ToString() != "") arrAn.answerId = qNbr; arrAn.answerId = qNbr; #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param2 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()), new SqlParameter("seq", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, seq), new SqlParameter("answerId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.answerId.ToString()), new SqlParameter("answer", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.answer.ToString()), new SqlParameter("topicType", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.topicType.ToString()), new SqlParameter("statusx", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "10"), new SqlParameter("creatUser", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "填寫問卷-外部使用者"), new SqlParameter("creatTime", SqlDbType.DateTime, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, dt.ToString("yyyy-MM-dd HH:mm:ss")) }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_answer (qId, seq, answerId, answer, topicType, statusx, creatUser, creatTime) values (@qId, @seq, @answerId, @answer, @topicType, @statusx, @creatUser, @creatTime) "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param2); if (errStr != "") { throw new Exception(errStr); } } #region OperLog 填寫問卷 //if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") //{ // string actStatus = ZhClass.SqlTool.GetOneDataValue(" SELECT top 1 statusx from Q30_answer where qId='" + actRow.qId + "' ").ToString(); // switch (actStatus) // { // case "10": // actStatus = "M"; // break; // case "20": // actStatus = "C"; // break; // default: // actStatus = "A"; // break; // } // #region Gen tbl_operLog1 Data (Add/Modify) // DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); // tbl_operLog1.Columns.Add("qId", typeof(string)); // tbl_operLog1.Columns.Add("seq", typeof(string)); // tbl_operLog1.Columns.Add("creatUser", typeof(string)); // DataRow operLogRow = tbl_operLog1.NewRow(); // //operLogRow["rowId"] =0; // operLogRow["actSerial"] = userData.actSerial; // operLogRow["sysUserId"] = 9; // operLogRow["actStatus"] = "P"; // operLogRow["qId"] = actRow.qId.ToString(); // operLogRow["seq"] = seq; // operLogRow["creatUser"] = "******"; // tbl_operLog1.Rows.Add(operLogRow); // #endregion // errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_answer", tbl_operLog1); // if (errStr != "") throw new Exception(errStr); //} #endregion } //ja.Add(itemObject); jo = new JObject(); jo.Add("status", "OK"); //jo.Add("row", ja); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.B00010 actRow) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { #region ACall_checkIsDBNull actRow.sysUserId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.sysUserId); actRow.userName = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userName); actRow.userId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userId); actRow.userPassword = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userPassword); actRow.userEmail = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userEmail); actRow.userPhone = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userPhone); actRow.userTel = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userTel); actRow.memo = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.memo); actRow.creatUser = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.creatUser); actRow.actUser = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.actUser); #endregion #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("sysUserId", SqlDbType.Int, 4, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysUserId), new SqlParameter("userName", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userName), new SqlParameter("userId", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userId), new SqlParameter("userPassword", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userPassword), new SqlParameter("userEmail", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userEmail), new SqlParameter("userPhone", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userPhone), new SqlParameter("userTel", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userTel), new SqlParameter("memo", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.memo), new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), //actRow.creatUser new SqlParameter("actUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), //actRow.actUser new SqlParameter("pk_sysUserId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "sysUserId", DataRowVersion.Original, actRow.sysUserId) }; #endregion strSql.Append("update S10_users set userName=@userName,userId=@userId,userPassword=@userPassword,userEmail=@userEmail,userPhone=@userPhone,userTel=@userTel,memo=@memo,actUser=@actUser,actTime=getdate() where sysUserId=@pk_sysUserId"); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #region OperLog 修改基本資料 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysUserId1", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "M"; operLogRow["sysUserId1"] = userData.sysUserId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q10_users", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion jo = new JObject(); jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActDisable(Models.question.Q00030_ActPublish actRow) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { #region ACall_checkIsDBNull actRow.qId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.qId); #endregion #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()) }; #endregion strSql.Clear(); strSql.Append("UPDATE Q30_questionMaster SET statusx='20', actTime=getDate() where qId=@qId"); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #region OperLog 停用問卷 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "S"; operLogRow["qId"] = actRow.qId.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_questionMaster", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion DateTime actTime = DateTime.Now; #region return Info JArray ja = new JArray(); var itemObject = new JObject(); itemObject.Add("statusxName", "停用"); itemObject.Add("statusx", "20"); itemObject.Add("actTime", actTime.ToString()); ja.Add(itemObject); jo = new JObject(); jo.Add("status", "OK"); jo.Add("row", ja); return(Content(JsonConvert.SerializeObject(jo), "application/json")); #endregion } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActDelete(string qId) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { strSql.Clear(); strSql.Append("select count(*) as c from Q30_answer where qId='" + qId + "' "); DataTable tbl_QueryData1 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData1"); if (tbl_QueryData1.Rows[0]["c"].ToString() != "0") { errStr = "此問卷已有人填寫,無法刪除"; if (errStr != "") { throw new Exception(errStr); } } #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, qId) }; #endregion strSql.Clear(); strSql.Append("Update Q30_questionMaster set statusx='30' where qId=@qId "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #region OperLog 刪除問卷 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "D"; operLogRow["qId"] = qId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_questionMaster", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion #region return Info jo = new JObject(); jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); #endregion } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.Q00035 actRow) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { DateTime dt = DateTime.Now; #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()), new SqlParameter("title", SqlDbType.NVarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.title.ToString()), new SqlParameter("description", SqlDbType.NVarChar, 1000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.description.ToString()), new SqlParameter("qNum", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qNum.ToString()), new SqlParameter("statusx", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "00"), new SqlParameter("actUser", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("actTime", SqlDbType.DateTime, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, dt.ToString("yyyy-MM-dd HH:mm:ss")) }; #endregion //switch (actRow.RowStatus.ToString()) //{ // case "A": // strSql.Clear(); // strSql.Append("Insert into Q30_questionMaster (qId, title, description, qNum, statusx, creatTime) values (@qId, @title, @description, @qNum, @statusx, @creatTime) "); // errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param); // if (errStr != "") throw new Exception(errStr); // break; // case "M": // break; //} strSql.Clear(); strSql.Append(" delete from Q30_questionDD where qId='" + actRow.qId.ToString() + "' "); strSql.Append(" delete from Q30_questionDetail where qId='" + actRow.qId.ToString() + "' "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString()); if (errStr != "") { throw new Exception(errStr); } strSql.Clear(); strSql.Append(" update Q30_questionMaster set title=@title, description=@description, qNum=@qNum, actUser=@actUser, actTime=getDate() where qId=@qId "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } if (actRow.arrQds != null) { int qNbr = 0; foreach (Models.question.Q00035_d arrQd in actRow.arrQds) { #region 提供題目題號 if (arrQd.topicType.ToString() != "lb") { qNbr++; } #endregion string topicType = arrQd.topicType.ToString(); #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param2 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()), new SqlParameter("seq", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.seq.ToString()), new SqlParameter("qNbr", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, qNbr), new SqlParameter("topic", SqlDbType.NVarChar, 1000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.topic.ToString()), new SqlParameter("topicType", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.topicType.ToString()), new SqlParameter("required", SqlDbType.Bit, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.required.ToString()), new SqlParameter("options", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.options.ToString()), new SqlParameter("creatUser", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("creatTime", SqlDbType.DateTime, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, dt.ToString("yyyy-MM-dd HH:mm:ss")) }; #endregion strSql.Clear(); if (arrQd.topicType.ToString() != "lb") //判斷目前是否為 說明標題,若為是則提供不儲存題號 { strSql.Append("Insert into Q30_questionDetail (qId, seq, qNbr, topic, topicType, required, options, creatTime, creatUser) values (@qId, @seq, @qNbr, @topic, @topicType, @required, @options, @creatTime, @creatUser) "); } else { strSql.Append("Insert into Q30_questionDetail (qId, seq, topic, topicType, required, options, creatTime, creatUser) values (@qId, @seq, @topic, @topicType, @required, @options, @creatTime, @creatUser) "); } errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param2); if (errStr != "") { throw new Exception(errStr); } if (topicType != "mt" && topicType != "li") { foreach (Models.question.Q00035_dd arrQdd in arrQd.arrQdds) { if (arrQdd.optionName == null) { arrQdd.optionName = ""; } #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param3 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()), new SqlParameter("seq", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQd.seq.ToString()), new SqlParameter("optionId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQdd.optionId.ToString()), new SqlParameter("optionName", SqlDbType.NVarChar, 1000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrQdd.optionName.ToString()), new SqlParameter("creatUser", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("creatTime", SqlDbType.DateTime, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, dt.ToString("yyyy-MM-dd HH:mm:ss")) }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_questionDD (qId, seq, optionId, optionName, creatTime, creatUser) values (@qId, @seq, @optionId, @optionName, @creatTime, @creatUser) "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param3); if (errStr != "") { throw new Exception(errStr); } } } } } #region OperLog 異動問卷題項 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = actRow.RowStatus.ToString(); operLogRow["qId"] = actRow.qId.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_questionMaster, Q30_questionDetail, Q30_questionDD", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion //ja.Add(itemObject); jo = new JObject(); jo.Add("status", "OK"); //jo.Add("row", ja); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.G00020 actRow) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo = new JObject(); try { actRow.type = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.type); actRow.sysObjectId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.sysObjectId); actRow.chked = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.chked); actRow.chkAll = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.chkAll); if (actRow.chkAll.ToString().Length > 0) { actRow.chkAll = actRow.chkAll.ToString().Substring(0, actRow.chkAll.ToString().Length - 1); } if (actRow.chked.ToString().Length > 0) { string[] USERS = actRow.chked.ToString().Split(','); strSql.Clear(); strSql.Append(""); strSql.Clear(); strSql.Append("delete from Q10_userVsObject where sysObjectId='" + actRow.sysObjectId.ToString() + "' and USERSSN in (" + actRow.chkAll.ToString() + ") and type='" + actRow.type.ToString() + "' "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString()); if (errStr != "") { throw new Exception(errStr); } for (int i = 0; i < USERS.Length; i++) { if (USERS[i] != "") { #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("USERSSN", SqlDbType.Int, 4, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, USERS[i]), new SqlParameter("sysObjectId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysObjectId.ToString()), new SqlParameter("type", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.type.ToString()), new SqlParameter("statusx", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "10"), new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId) }; #endregion strSql.Clear(); strSql.Append("Insert into Q10_userVsObject (USERSSN, sysObjectId, type, statusx, creatUser, creatTime) values (@USERSSN, @sysObjectId, @type, @statusx, @creatUser, getDate()) "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } } } } #region OperLog 異動群組資料 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysObjectId", typeof(string)); tbl_operLog1.Columns.Add("type", typeof(string)); tbl_operLog1.Columns.Add("USERSSN", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "M"; operLogRow["sysObjectId"] = actRow.sysObjectId.ToString(); operLogRow["type"] = actRow.type.ToString(); operLogRow["USERSSN"] = actRow.chked.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "S10_userGroup", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult DeleteSingle(string pks) { try { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); string[] pk = pks.Split('/'); object pk_sysObjectId = pk[0]; //查詢是否有使用者隸屬於該群組下 strSql.Remove(0, strSql.Length); int count = Convert.ToInt32(SqlTool.GetOneDataValue("SELECT COUNT(*) FROM Q10_userVsObject WHERE sysObjectId='" + pk_sysObjectId + "'")); if (count == 0) { #region 刪除 Server端的資料 strSql.Remove(0, strSql.Length); strSql.Append("update Q10_Objects set statusx='30' where sysObjectId=@pk_sysObjectId"); SqlParameter[] param = { new SqlParameter("pk_sysObjectId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pk_sysObjectId) }; errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #region OperLog 刪除群組 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysObjectId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "D"; operLogRow["sysObjectId"] = pk_sysObjectId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "S10_userGroup", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion } else { errStr = "Can't Delete"; } #endregion if (errStr == "") { return(Json("OK", JsonRequestBehavior.DenyGet)); } else if (errStr == "Can't Delete") { return(Json("Can't Delete", JsonRequestBehavior.DenyGet)); } else { return(Json(errStr, JsonRequestBehavior.DenyGet)); } #endregion } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.DenyGet)); } }
public ActionResult ActSingle(Models.question.G00010 actRow)//接收單筆資料方式 { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { actRow.sysObjectId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.sysObjectId); actRow.memo = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.memo); #region 判斷啟用中 值,不可重複 //RE0020 //errStr += ZhWebClassV1.CheckObj.Chk_ColumnValue(actRow.RowStatus.ToString(), "userGroup", "userGroupName", "使用者群組名稱", actRow.userGroupName.ToString(), "and sysUserGroupId !='" + actRow.sysUserGroupId.ToString() + "' and corpUser is null "); strSql.Clear(); if (actRow.RowStatus.ToString() == "A") { strSql.Append("select * from Q10_Objects where objectName='" + actRow.objectName.ToString() + "' and statusx='10' and creatUser='******' "); } else { strSql.Append("select * from Q10_Objects where objectName='" + actRow.objectName.ToString() + "' and statusx='10' and sysObjectId <> '" + actRow.sysObjectId.ToString() + "' and creatUser='******' "); } DataTable tbl_QueryData2 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData2"); if (tbl_QueryData2.Rows.Count > 0) { errStr = "啟用中之使用者群組名稱:【" + actRow.objectName.ToString() + "】,<br>不可重複 "; } else { errStr = ""; } if (errStr != "") { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", errStr); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } #endregion #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("sysObjectId", SqlDbType.Int, 4, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysObjectId), new SqlParameter("objectId", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.objectId), new SqlParameter("objectName", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.objectName), new SqlParameter("statusx", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.statusx), new SqlParameter("memo", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.memo), new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("actUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId) }; #endregion strSql.Remove(0, strSql.Length); switch (actRow.RowStatus.ToString()) { case "A": strSql.Clear(); strSql.Append("insert into Q10_Objects (objectId,objectName,statusx,memo,creatUser,creatTime) values (@objectId,@objectName,@statusx,@memo,@creatUser,getdate())"); strSql.Append(" SELECT @sysObjectId = SCOPE_IDENTITY() "); actRow.creatUser = userData.userName; actRow.creatTime = DateTime.Now; errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } actRow.sysObjectId = param[0].Value; break; case "M": //,creatUser=@creatUser,creatTime=@creatTime strSql.Append("update Q10_Objects set objectId=@objectId,objectName=@objectName,statusx=@statusx,memo=@memo,actUser=@actUser,actTime=getdate() where sysObjectId=@sysObjectId"); actRow.actUser = userData.userName; actRow.actTime = DateTime.Now; errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } strSql.Remove(0, strSql.Length); strSql.Append("update Q10_userVsObject set statusx='" + actRow.statusx.ToString() + "' where sysObjectId='" + actRow.sysObjectId.ToString() + "' "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } break; } #region OperLog 異動群組資料 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysObjectId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = actRow.RowStatus.ToString(); operLogRow["sysObjectId"] = actRow.sysObjectId.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q10_Objects", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion if (errStr == "") { //return Json("OK", JsonRequestBehavior.DenyGet); jo = new JObject(); jo.Add("status", "OK"); jo.Add("row", getJsonForGrid(actRow)); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } else { //return Json(errStr, JsonRequestBehavior.DenyGet); jo = new JObject(); jo.Add("status", "error"); jo.Add("error", errStr); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } } catch (Exception ex) { //return Json(ex.Message, JsonRequestBehavior.DenyGet); jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult ActSingle(Models.question.W00015_act actRow, string qNbr) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; string seq = ""; try { DateTime dt = DateTime.Now; if (actRow.arrAns != null) { #region 判斷目前為第幾位填答人數 strSql.Clear(); strSql.Append(" select max(seq) as max from Q30_answer where qId='" + actRow.qId.ToString() + "' and creatUser='******' "); DataTable tbl_QueryData1 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData1"); #endregion if (tbl_QueryData1.Rows.Count > 0 && tbl_QueryData1.Rows[0][0].ToString() != "") { seq = tbl_QueryData1.Rows[0][0].ToString(); } else { //進來代表這個人沒有做過問卷 DataTable tbl_QueryData2 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, " select max(seq) as max from Q30_answer where qId='" + actRow.qId.ToString() + "' ", "tbl_QueryData2"); if (tbl_QueryData2.Rows.Count == 0 || tbl_QueryData2.Rows[0][0].ToString() == "") {//如果都沒人填寫過則設為1 seq = "1"; } else { //如果有人填寫過就+1 seq = (Convert.ToInt32(tbl_QueryData2.Rows[0][0].ToString()) + 1).ToString(); } } //先刪除原本的作答再填入新的作答 if (!string.IsNullOrEmpty(qNbr)) { strSql.Clear(); strSql.Append("delete Q30_answer where qId='" + actRow.qId.ToString() + "' and creatUser='******' and answerId='" + qNbr + "' "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString()); if (errStr != "") { throw new Exception(errStr); } } foreach (Models.question.W00015_act_d arrAn in actRow.arrAns) { arrAn.answer = ZhConfig.ZhIniObj.ACall_checkIsDBNull(arrAn.answer); if (arrAn.topicType.ToString() == "cb" && arrAn.answer.ToString() != null && arrAn.answer.ToString() != "") { arrAn.answer = arrAn.answer.ToString().Substring(0, arrAn.answer.ToString().Length - 1); } if (arrAn.topicType.ToString() == "lb") { arrAn.answer = ""; } //題號對應題號 arrAn.answerId = qNbr; #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param2 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.qId.ToString()), new SqlParameter("seq", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, seq), new SqlParameter("answerId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.answerId.ToString()), new SqlParameter("answer", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.answer.ToString()), new SqlParameter("topicType", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, arrAn.topicType.ToString()), new SqlParameter("statusx", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "10"), new SqlParameter("creatUser", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.userId.ToString()), new SqlParameter("creatTime", SqlDbType.DateTime, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, dt.ToString("yyyy-MM-dd HH:mm:ss")) }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_answer (qId, seq, answerId, answer, topicType, statusx, creatUser, creatTime) values (@qId, @seq, @answerId, @answer, @topicType, @statusx, @creatUser, @creatTime) "); errStr = SqlTool.ExecuteNonQuery(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), param2); if (errStr != "") { throw new Exception(errStr); } } #region OperLog 填寫問卷 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { string actStatus = ZhClass.SqlTool.GetOneDataValue(" SELECT top 1 statusx from Q30_answer where qId='" + actRow.qId + "' ").ToString(); switch (actStatus) { case "10": actStatus = "M"; break; case "20": actStatus = "C"; break; default: actStatus = "A"; break; } #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); tbl_operLog1.Columns.Add("seq", typeof(string)); tbl_operLog1.Columns.Add("creatUser", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = actStatus; //operLogRow["actStatus"] = actRow.RowStatus.ToString(); operLogRow["qId"] = actRow.qId.ToString(); operLogRow["seq"] = seq; operLogRow["creatUser"] = userData.userId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_answer", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion } //ja.Add(itemObject); jo = new JObject(); jo.Add("status", "OK"); //jo.Add("row", ja); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
public ActionResult DeleteSingle(string pks) { try { string[] pk = pks.Split('/'); object pk_sysUserId = pk[0]; #region 刪除 後端資料庫 strSql.Append("Update S10_users set statusx='30' where sysUserId=@pk_sysUserId"); #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("pk_sysUserId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "sysUserId", DataRowVersion.Original, pk_sysUserId) }; #endregion errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); #region OperLog 異動使用者資料 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysUserId1", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "D"; operLogRow["sysUserId1"] = pk_sysUserId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "S10_users", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion if (errStr != "") { return(Json(errStr, JsonRequestBehavior.DenyGet)); } else { return(Json("OK", JsonRequestBehavior.DenyGet)); } #endregion } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.DenyGet)); } }
public static string SaveOperLog(string strConnection, string funcId, string tableName, DataTable OperLogTable) { object actStatus; object actSerial; object sysUserId; object rowId = null; DataRow[] delRow; string strSql = "insert into S90_operLog (actSerial,sysUserId, funcId,actStatus,tableName,tblPrimaryKeysAndValues) values (@actSerial,@sysUserId, @funcId,@actStatus,@tableName,@tblPrimaryKeysAndValues);SELECT @rowId = SCOPE_IDENTITY()"; for (int i = 0; i < OperLogTable.Rows.Count; i++) { #region KeyAndValues string strPKeysAndValues = ""; string pKeyName; string pKeyValue; //若有需要串接到operLogDeatil 會用到,目前用不到 ,且一開始rowId 若有值只是自動編來跟 operLogDeatil 串接的 //oriRowId = OperLogTable.Rows[i][0].ToString(); actStatus = OperLogTable.Rows[i]["actStatus"]; actSerial = OperLogTable.Rows[i]["actSerial"]; sysUserId = OperLogTable.Rows[i]["sysUserId"]; for (int j = 5; j < OperLogTable.Columns.Count; j++) { pKeyName = OperLogTable.Columns[j].ColumnName; pKeyValue = OperLogTable.Rows[i][j].ToString().Trim(); strPKeysAndValues += pKeyName + "='" + pKeyValue + "'|"; } strPKeysAndValues = strPKeysAndValues.Substring(0, strPKeysAndValues.Length - 1); #endregion SqlParameter[] param = new SqlParameter[7]; param[0] = new SqlParameter("@sysUserId", SqlDbType.Char, 10); param[0].Value = sysUserId; param[1] = new SqlParameter("@funcId", SqlDbType.Char, 8); param[1].Value = funcId; param[2] = new SqlParameter("@actStatus", SqlDbType.Char, 1); param[2].Value = actStatus; param[3] = new SqlParameter("@tableName", SqlDbType.VarChar, 255); param[3].Value = tableName; param[4] = new SqlParameter("@tblPrimaryKeysAndValues", SqlDbType.NVarChar, 255); param[4].Value = strPKeysAndValues; param[5] = new SqlParameter("@rowId", SqlDbType.Int, 4, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, rowId); param[5].Value = rowId; param[6] = new SqlParameter("@actSerial", SqlDbType.Int, 4); param[6].Value = actSerial; string errStr = SqlTool.ExecuteNonQuery(strConnection, strSql, param); if (errStr != "") { delRow = OperLogTable.Select("actStatus='*'"); foreach (DataRow dr in delRow) { dr.Delete(); } return(errStr); } OperLogTable.Rows[i]["actStatus"] = "*"; rowId = param[5].Value; //有需要時 寫入 異動前後的值到operLogDetail } delRow = OperLogTable.Select("actStatus='*'"); foreach (DataRow dr in delRow) { dr.Delete(); } OperLogTable.AcceptChanges(); return(""); }
public ActionResult ActSingle(Models.question.Q00030 actRow) { JObject jo; ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); try { #region ACall_checkIsDBNull actRow.title = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.title); actRow.description = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.description); #endregion #region 取得問卷單號 string qId = getQId(); #endregion #region 存入問卷主檔 #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, qId), new SqlParameter("title", SqlDbType.NVarChar, 255, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.title), new SqlParameter("description", SqlDbType.NVarChar, 1000, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.description), new SqlParameter("qNum", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, 0), new SqlParameter("statusx", SqlDbType.Char, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "00"), new SqlParameter("creatUser", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId.ToString()) }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_questionMaster (qId, title, description, qNum, statusx, creatUser, creatTime) values (@qId, @title, @description, @qNum, @statusx, @creatUser, getDate()) "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #endregion #region 存入問卷日期檔 #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param3 = { new SqlParameter("qId", SqlDbType.Char, 10, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, qId), new SqlParameter("creatUser", SqlDbType.Char, 10, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId.ToString()) }; #endregion strSql.Clear(); strSql.Append("Insert into Q30_questionDate (qId, creatUser, creatTime) values (@qId, @creatUser, getDate()) "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param3); if (errStr != "") { throw new Exception(errStr); } #endregion #region OperLog 修改問卷 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("qId", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "A"; operLogRow["qId"] = qId; tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "Q30_questionMaster", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion #region return Info jo = new JObject(); jo.Add("status", "OK"); jo.Add("qId", qId); return(Content(JsonConvert.SerializeObject(jo), "application/json")); #endregion } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }
//public ActionResult DeleteSingle(C10_zip delRec) public ActionResult ActRows(List <Models.ModelBase.Row_userGroupPermissions> addRows) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); DataTable tbl_limit = ZhWebClassV3.CmnObjV3.Get_tbl_limit(ZhConfig.IsAddIndexZero.No); JObject jo; //2010 6/25 應該改成 交易式處理全部成功 或是全部失敗 foreach (Models.ModelBase.Row_userGroupPermissions actRow in addRows) { strSql.Remove(0, strSql.Length); string limitId = tbl_limit.Select("limitName='" + actRow.limitName.ToString() + "'")[0]["limitId"].ToString(); switch (actRow.realRow.ToString()) { case "0": //新增 { actRow.creatUser = userData.userName; actRow.creatTime = DateTime.Now; //actRow.actUser = userData.userName; //actRow.actTime = DateTime.Now; strSql.Append("insert into S10_userGroupPermissions (sysUserGroupId,sysMenuId,limitId,creatUser,creatTime) values (@sysUserGroupId,@sysMenuId,@limitId,'" + userData.sysUserId + "',getdate())"); } break; case "1": //修改 { actRow.actUser = userData.userName; actRow.actTime = DateTime.Now; strSql.Append("update S10_userGroupPermissions set sysUserGroupId=@sysUserGroupId,sysMenuId=@sysMenuId,limitId=@limitId,actUser='******',actTime=getdate() where sysUserGroupId=@sysUserGroupId and sysMenuId=@sysMenuId"); } break; } #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("sysUserGroupId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysUserGroupId), new SqlParameter("sysMenuId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysMenuId), new SqlParameter("limitId", SqlDbType.Char, 1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, limitId), new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), new SqlParameter("actUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId) //new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.creatUser), //new SqlParameter("actUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.actUser) }; #endregion errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { //return Json("ERROR", errStr, JsonRequestBehavior.DenyGet); jo = new JObject(); jo.Add("status", "error"); jo.Add("error", errStr); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } } jo = new JObject(); jo.Add("status", "OK"); jo.Add("rows", getJsonForGrid(addRows)); //return Json("OK", JsonConvert.SerializeObject(addRows), JsonRequestBehavior.DenyGet); return(Content(JsonConvert.SerializeObject(jo), "application/json")); }
public ActionResult ActSingle(List <Models.question.B00010> actRows) { ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData(); JObject jo; try { #region 判斷匯入的帳號是否重覆 string userIdGroup = ""; foreach (Models.question.B00010 actRow in actRows) { userIdGroup = userIdGroup + "'" + actRow.userId.ToString().Trim() + "',"; } userIdGroup = userIdGroup.Substring(0, userIdGroup.Length - 1); strSql.Clear(); strSql.Append("select count(*) as C from S10_users where userId in (" + userIdGroup + ") and statusx='10' "); DataTable tbl_QueryData1 = ZhClass.SqlTool.GetDataTable(ZhConfig.GlobalSystemVar.StrConnection1, strSql.ToString(), "tbl_QueryData1"); if (tbl_QueryData1.Rows[0]["C"].ToString() != "0") { errStr = "已有相同帳號存在於資料庫中,請確認。"; if (errStr != "") { throw new Exception(errStr); } } #endregion #region 開始匯入資料庫 foreach (Models.question.B00010 actRow in actRows) { #region ACall_checkIsDBNull actRow.sysUserId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.sysUserId); actRow.userName = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userName); actRow.userId = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userId); actRow.userPassword = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userPassword); actRow.userEmail = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userEmail); actRow.userPhone = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userPhone); actRow.userTel = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.userTel); actRow.statusx = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.statusx); actRow.memo = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.memo); actRow.creatUser = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.creatUser); actRow.actUser = ZhConfig.ZhIniObj.ACall_checkIsDBNull(actRow.actUser); #endregion #region 設置 要傳入的 SqlParameter 資料 SqlParameter[] param = { new SqlParameter("sysUserId", SqlDbType.Int, 4, ParameterDirection.InputOutput, false, 0, 0, "", DataRowVersion.Proposed, actRow.sysUserId), new SqlParameter("userName", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userName), new SqlParameter("userId", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userId), new SqlParameter("userPassword", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userPassword), new SqlParameter("userEmail", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userEmail), new SqlParameter("userPhone", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userPhone), new SqlParameter("userTel", SqlDbType.VarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.userTel), new SqlParameter("statusx", SqlDbType.VarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, "10"), new SqlParameter("memo", SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, actRow.memo), new SqlParameter("creatUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), //actRow.creatUser new SqlParameter("actUser", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, userData.sysUserId), //actRow.actUser new SqlParameter("pk_sysUserId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "sysUserId", DataRowVersion.Original, actRow.sysUserId) }; #endregion strSql.Clear(); strSql.Append("Insert into S10_users (userName, userId, userPassword, userEmail, userPhone, userTel, statusx, memo, creatUser, creatTime) values (@userName, @userId, @userPassword, @userEmail, @userPhone, @userTel, @statusx, @memo, @creatUser, getDate()) "); strSql.Append("SELECT @sysUserId = SCOPE_IDENTITY()"); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } actRow.sysUserId = param[0].Value; #region OperLog 異動使用者資料 if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "") { #region Gen tbl_operLog1 Data (Add/Modify) DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1(); tbl_operLog1.Columns.Add("sysUserId1", typeof(string)); DataRow operLogRow = tbl_operLog1.NewRow(); //operLogRow["rowId"] =0; operLogRow["actSerial"] = userData.actSerial; operLogRow["sysUserId"] = userData.sysUserId; operLogRow["actStatus"] = "A"; operLogRow["sysUserId1"] = actRow.sysUserId.ToString(); tbl_operLog1.Rows.Add(operLogRow); #endregion errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "S10_users", tbl_operLog1); if (errStr != "") { throw new Exception(errStr); } } #endregion #region 給予權限類別,目前預設為4:問卷設計師 strSql.Clear(); strSql.Append("insert into S10_userVsGroup (sysUserId,sysUserGroupId,statusx) values ('" + actRow.sysUserId.ToString() + "','4','10') "); errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param); if (errStr != "") { throw new Exception(errStr); } #endregion } #endregion jo = new JObject(); jo.Add("status", "OK"); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } catch (Exception ex) { jo = new JObject(); jo.Add("status", "error"); jo.Add("error", ex.Message); return(Content(JsonConvert.SerializeObject(jo), "application/json")); } }