/// <summary> /// is record exsit /// </summary> /// <param name="absentinfo"></param> /// <returns></returns> public bool isRecordExist(AbsentInfo absentInfo) { string sql = "select count(*) from absent where absentdate=@absentdate and absentuserid=@absentuserid"; Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("@absentdate", absentInfo.absentdate); dict.Add("@absentuserid", absentInfo.absentuserid); return(SqlHelper.IsExists(sql, dict)); }
public bool deleteAbsentInfo(AbsentInfo absentInfo) { bool isExist = isRecordExist(absentInfo); if (!isExist) { return(true); } return(dalTableAbsent.deleteAbsentInfo(absentInfo)); }
/// <summary> /// insert bus info /// </summary> /// <param name="absentinfo"></param> /// <returns></returns> public bool insertAbsentInfo(AbsentInfo absentInfo) { bool isExist = isRecordExist(absentInfo); if (isExist) { return(true); } return(dalTableAbsent.insertAbsentInfo(absentInfo)); }
public bool deleteAbsentInfo(AbsentInfo absentInfo) { string sql = "delete from absent where absentdate=@absentdate and absentuserid=@absentuserid"; Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("@absentdate", absentInfo.absentdate); dict.Add("@absentuserid", absentInfo.absentuserid); int count = SqlHelper.ExecuteNonQuery(sql, dict); if (count > 0) { return(true); } else { return(false); } }
/// <summary> /// insert bus info /// </summary> /// <param name="absentinfo"></param> /// <returns></returns> public bool insertAbsentInfo(AbsentInfo absentInfo) { string sql = "insert into absent (absentdate,absentuserid)values(@absentdate,@absentuserid)"; Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("@absentdate", absentInfo.absentdate); dict.Add("@absentuserid", absentInfo.absentuserid); int count = SqlHelper.ExecuteNonQuery(sql, dict); if (count > 0) { return(true); } else { return(false); } }
public void ProcessRequest(HttpContext context) { try { Utils.WriteTraceLog("GetAbsentState start"); StreamReader reader = new StreamReader(context.Request.InputStream); string str = reader.ReadToEnd(); reader.Close(); string ResultCode = string.Empty; BLLBus bLLBus = new BLLBus(); BLLUsers bLLUsers = new BLLUsers(); BLLAbsent bLLAbsent = new BLLAbsent(); Dictionary <string, object> dict = new Dictionary <string, object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); RequestData requestData = jsSerializer.Deserialize <RequestData>(str); if (requestData == null) { ResultCode = "3101"; } else if (requestData.StudentID == string.Empty || requestData.StudentID == null) { ResultCode = "3102"; } else if (requestData.CurrentDate == string.Empty || requestData.CurrentDate == null) { ResultCode = "3103"; } else { ResultCode = "0000"; AbsentInfo absentInfo = new AbsentInfo(); absentInfo.absentdate = requestData.CurrentDate; absentInfo.absentuserid = requestData.StudentID; bool isExist = bLLAbsent.isRecordExist(absentInfo); if (isExist) { dict.Add("AbsentStatus", "true"); } else { dict.Add("AbsentStatus", "false"); } } dict.Add("ResultCode", ResultCode); context.Response.ContentType = "text/html"; context.Response.Write(jsSerializer.Serialize(dict)); Utils.WriteTraceLog("GetAbsentState ResultCode====" + ResultCode); Utils.WriteTraceLog("GetAbsentState end"); } catch (Exception ex) { Dictionary <string, string> dict = new Dictionary <string, string>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); dict.Add("ResultCode", "9991"); context.Response.ContentType = "text/html"; context.Response.Write(jsSerializer.Serialize(dict)); Utils.WriteTraceLog("GetAbsentState Exception " + ex); Utils.WriteTraceLog("GetAbsentState ResultCode====9991"); Utils.WriteTraceLog("GetAbsentState end"); } }
/// <summary> /// is record exsit /// </summary> /// <param name="absentinfo"></param> /// <returns></returns> public bool isRecordExist(AbsentInfo absentInfo) { return(dalTableAbsent.isRecordExist(absentInfo)); }
public void ProcessRequest(HttpContext context) { try { Utils.WriteTraceLog("UploadAbsentState start"); StreamReader reader = new StreamReader(context.Request.InputStream); string str = reader.ReadToEnd(); reader.Close(); string ResultCode = string.Empty; BLLBus bLLBus = new BLLBus(); BLLUsers bLLUsers = new BLLUsers(); BLLAbsent bLLAbsent = new BLLAbsent(); Dictionary <string, object> dict = new Dictionary <string, object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); RequestData requestData = jsSerializer.Deserialize <RequestData>(str); if (requestData == null) { ResultCode = "3001"; } else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null) { ResultCode = "3002"; } else if (requestData.ParentID == string.Empty || requestData.ParentID == null) { ResultCode = "3003"; } else if (!bLLUsers.verifyUserID(requestData.ParentID, requestData.AccessToken)) { ResultCode = "3004"; } else if (requestData.CurrentDate == string.Empty || requestData.CurrentDate == null) { ResultCode = "3005"; } else if (requestData.AbsentState == string.Empty || requestData.AbsentState == null) { ResultCode = "3007"; } else { AbsentInfo absentInfo = new AbsentInfo(); absentInfo.absentdate = requestData.CurrentDate; absentInfo.absentuserid = requestData.ParentID; bool result = false; if (requestData.AbsentState.Equals("true")) { result = bLLAbsent.insertAbsentInfo(absentInfo); } else if (requestData.AbsentState.Equals("false")) { result = bLLAbsent.deleteAbsentInfo(absentInfo); } if (!result) { ResultCode = "3006"; } else { ResultCode = "0000"; } } dict.Add("ResultCode", ResultCode); context.Response.ContentType = "text/html"; context.Response.Write(jsSerializer.Serialize(dict)); Utils.WriteTraceLog("UploadAbsentState ResultCode====" + ResultCode); Utils.WriteTraceLog("UploadAbsentState end"); } catch (Exception ex) { Dictionary <string, string> dict = new Dictionary <string, string>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); dict.Add("ResultCode", "9991"); context.Response.ContentType = "text/html"; context.Response.Write(jsSerializer.Serialize(dict)); Utils.WriteTraceLog("UploadAbsentState Exception " + ex); Utils.WriteTraceLog("UploadAbsentState ResultCode====9991"); Utils.WriteTraceLog("UploadAbsentState end"); } }