public string InsertRequestTeacher(string id, string date, string teaId, string status, string sub_date, string reason) { int reqStat = Convert.ToInt32(status); double TeaID = Convert.ToDouble(teaId); int lesId = Convert.ToInt32(id); DateTime trueDate = Convert.ToDateTime(date); DateTime reqTrueDate = Convert.ToDateTime(sub_date); teachersRequests teaReq = new teachersRequests(lesId, trueDate, TeaID, reqStat, reqTrueDate, reason); int isReq = teaReq.CheckRequestCAL(); if (isReq > 0) { return(null); } int numEffected = teaReq.InsertTeacherRequest(); JavaScriptSerializer js = new JavaScriptSerializer(); // serialize to string if (numEffected == 0) { return(null); } string jsonStringGetTurtering = js.Serialize(numEffected); return(jsonStringGetTurtering); }
protected void btnSend_Click(object sender, EventArgs e) { double teaID = (double)(Session["TeaId"]); int lessNumber = Convert.ToInt32(Session["selectedLessonNum"]); DateTime lessDate = Convert.ToDateTime(Session["LessonDate"]); DateTime reqDate = Convert.ToDateTime(Session["requestDate"]); int reqStatus = 2; string reqReason = txtReason.Text; int flg = 0; teachersRequests teaReq; DataTable dt = this.GetRequests(); foreach (DataRow dr in dt.Rows) { DateTime dat = (DateTime)(dr["TeaReq__LessDate"]); int lesNum = Convert.ToInt32(dr["TeaReq__LessId"]); double ReqTeaID = Convert.ToDouble(dr["TeaReq_TeaId"]); if (dat == lessDate && lesNum == lessNumber && ReqTeaID == teaID) { flg = 1; } } if (flg == 0) { try { teaReq = new teachersRequests(lessNumber, lessDate, teaID, reqStatus, reqDate, reqReason); int numEffected = teaReq.InsertTeacherRequest(); } catch (Exception ex) { Response.Write("There was an error " + ex.Message); } } Server.TransferRequest(Request.Url.AbsolutePath, false); }