void CancelStudentAdmission(string UniStudID, string sCancelReason) { string[] StudentIDs = UniStudID.Split('|'); string sResult = string.Empty; //string sISDirectAdmission = string.Empty; Classes.clsUser user = (Classes.clsUser)Session["User"]; Hashtable oHt = new Hashtable(); oHt["pk_Uni_ID"] = StudentIDs[0]; oHt["pk_Year"] = StudentIDs[1]; oHt["pk_Student_ID"] = StudentIDs[2]; oHt["pk_Fac_ID"] = StudentIDs[3]; oHt["pk_Cr_ID"] = StudentIDs[4]; oHt["pk_MoLrn_ID"] = StudentIDs[5]; oHt["pk_Ptrn_ID"] = StudentIDs[6]; oHt["pk_Brn_ID"] = StudentIDs[7]; oHt["pk_CrPr_Details_ID"] = StudentIDs[9]; oHt["pk_CrPrCh_ID"] = StudentIDs[10]; oHt["CrPr_Seq"] = StudentIDs[8]; oHt["CrPrCh_Seq"] = StudentIDs[11]; //oHt["Admission_Form_No"] = StudentIDs[12]; //oHt["AdmissionMode"] = StudentIDs[13]; //oHt["CrPr_OrderNo"] = StudentIDs[14]; //oHt["MINumber"] = StudentIDs[15]; //oHt["IsDirectAdmission"] = sISDirectAdmission; //oHt["Prn_number "] = ((Label)((Repeater)(source)).Items[e.Item.ItemIndex].FindControl("lblPRN")).Text; oHt["User"] = user.User_ID; oHt["CancellationReason"] = sCancelReason; //string sAdmissionFormNo = StudentIDs[12]; //string sAdmissionMode = StudentIDs[13]; //int sCrPr_OrderNo = Convert.ToInt16(StudentIDs[14]); //string sMINumber = StudentIDs[15]; //bool isDirectAdmission = StudentIDs[16].Equals("1") ? true : false; //oHt["CancellationReason"]=txtReasonforCancellation. clsStudent oStudent = new clsStudent(); clsOthers sOthers = new clsOthers(); sResult = oStudent.CancelAdmission(oHt); switch (sResult) { case "N": //#region Followng code is added to cancel the admission at OA side, call to API //string OaMessage = string.Empty; //Hashtable oHs = new Hashtable(); //oHs.Add("pk_Uni_ID", StudentIDs[0]); //if (sOthers.Allow_CancelAdmissionAtOASide(oHs)) //{ // if (sAdmissionMode == "11" || sAdmissionMode == "12") //OA unregistered // { // if (sCrPr_OrderNo.Equals(1) || isDirectAdmission) // { // clsUserLogin userLogin = new clsUserLogin(); // DataSet ds = new DataSet(); // DataTable dt = new DataTable("CancelAdmissionTable"); // dt.Columns.Add(new DataColumn("ApplicationID", typeof(string))); // dt.Columns.Add(new DataColumn("DUDCFlag", typeof(string))); // dt.Columns.Add(new DataColumn("Username", typeof(string))); // dt.Columns.Add(new DataColumn("MINumber", typeof(string))); // DataRow dr = dt.NewRow(); // dr["ApplicationID"] = sAdmissionFormNo; // dr["DUDCFlag"] = "DU"; // dr["Username"] = user.User_Name; // dr["MINumber"] = sMINumber; // dt.Rows.Add(dr); // ds.Tables.Add(dt); // string dtToJson = string.Empty; // dtToJson = JsonConvert.SerializeObject(ds, Formatting.Indented); // //old Code commented for API CALL // /* // try // { // string apiPath = userLogin.getSyncURL() + "PostStudentCancelAdmission"; // using (ExtendedWebClient client = new ExtendedWebClient()) // { // client.Headers.Add("content-type", "application/json; charset=utf-8"); // client.Encoding = System.Text.Encoding.UTF8; // OaMessage = client.UploadString(apiPath, "POST", dtToJson); // } // }*/ // try // { // string apiPath = userLogin.getSyncURL() + "PostStudentCancelAdmission"; // var httpWebRequest = (HttpWebRequest)WebRequest.Create(apiPath); // httpWebRequest.Method = "POST"; // httpWebRequest.ContentType = "application/json"; // using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) // { // streamWriter.Write(dtToJson); // streamWriter.Flush(); // streamWriter.Close(); // var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); // using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) // { // OaMessage = streamReader.ReadToEnd(); // } // } // } // catch (Exception exOA) // { // //Log the error in database Table // Hashtable oHsErrorLog = new Hashtable(); // string[] sStudentIDs = UniStudID.Split('|'); // oHsErrorLog.Add("pk_Uni_ID", sStudentIDs[0]); // oHsErrorLog.Add("pk_Year", sStudentIDs[1]); // oHsErrorLog.Add("pk_Student_ID", sStudentIDs[2]); // oHsErrorLog.Add("pk_Fac_ID", sStudentIDs[3]); // oHsErrorLog.Add("pk_Cr_ID", sStudentIDs[4]); // oHsErrorLog.Add("pk_MoLrn_ID", sStudentIDs[5]); // oHsErrorLog.Add("pk_Ptrn_ID", sStudentIDs[6]); // oHsErrorLog.Add("pk_Brn_ID", sStudentIDs[7]); // oHsErrorLog.Add("pk_CrPr_Details_ID", sStudentIDs[8]); // oHsErrorLog.Add("CrPr_Seq", sStudentIDs[9]); // oHsErrorLog.Add("CrPrCh_ID", sStudentIDs[10]); // oHsErrorLog.Add("CrPrCh_Seq", sStudentIDs[11]); // oHsErrorLog.Add("Error_Msg", exOA.Message); // oHsErrorLog.Add("UserName", user.User_Name); // sOthers.WriteOAErrorLog(oHsErrorLog); // OaMessage = "There is some issue while updating at OA side, Please contact Administrator."; // } // } // } //} ///*******************************************************************************************/ //#endregion lblMsg.Text = "Admission of the selected term cancelled successfully."; lblMsg.CssClass = "saveNote"; break; case "Y": lblMsg.Text = "Admission of the selected term cannot be cancelled."; lblMsg.CssClass = "errorNote"; break; case "E": lblMsg.Text = "Admission of the selected term could not be cancelled as the Seat number is generated for this Term."; lblMsg.CssClass = "errorNote"; break; case "I": lblMsg.Text = "Admission of the selected term could not be cancelled as the Invoice is generated for this Term."; lblMsg.CssClass = "errorNote"; break; case "": lblMsg.Text = "Admission of the selected term cannot be cancelled."; lblMsg.CssClass = "errorNote"; break; default: break; } DisplayStudentDetails(); }