protected void btnExport_Click(object sender, EventArgs e) { //Get student choices done through our application //----------------------------------------------- string strSQL = "SELECT * FROM mwExport where gradenumber = 9 and school_code = '" + ddlSchoolCode.SelectedValue.ToString() + "'"; SqlConnection oConn = new SqlConnection(strConn); oConn.Open(); SqlDataAdapter oDA = new SqlDataAdapter(strSQL, oConn); DataTable dtb = new DataTable(); oDA.Fill(dtb); //grdExportData.DataSource = dtb; //grdExportData.DataBind(); //oConn.Close(); //------------------------------------------------ //Maplewood code com.maplewood.www.StAc_StuChoice stuChoice = new com.maplewood.www.StAc_StuChoice(); int iCounter = 0; foreach (DataRow dr in dtb.Rows) { stuChoice.Student_Choices.AddStudent_ChoicesRow(iCounter); stuChoice.Student_Choice_Details.AddStudent_Choice_DetailsRow(dr["board_code"].ToString(), dr["school_code"].ToString(), dr["course_code"].ToString(), dr["student_code"].ToString(), dr["choice_type"].ToString(), dr["choice_type_title"].ToString(), stuChoice.Student_Choices[iCounter] ); iCounter += 1; } //Data that will be sent to MW web service grdExportData.DataSource = stuChoice.Student_Choice_Details; grdExportData.DataBind(); //Call Update student choices and get errors com.maplewood.www.StAc_StuChoiceUpdate stuResults; Integration.Timeout = 150000; stuResults = Integration.UpdateStuChoices(ddlSchoolCode.SelectedValue.ToString(), "Y", "N", stuChoice); DataTable dtbErrors = stuResults.UpdateError; grdExportResults.DataSource = dtbErrors; grdExportResults.DataBind(); //Delete any old errors for this school //strSQL = "delete from TransferErrors where schoolcode = '" + ddlSchoolCode.SelectedValue.ToString() + "'"; //SqlCommand oDel = new SqlCommand(strSQL, oConn); //oDel.ExecuteNonQuery(); //reinsert any new errors occured on Export foreach (DataRow dr in dtbErrors.Rows) { strSQL = "INSERT INTO TransferErrors(SystemNameId, SchoolCode, sisStudentId, CourseCode, ErrorMessage)"; strSQL += "VALUES(5, '" + dr["school_code"].ToString() + "','" + dr["student_code"].ToString() + "','" + dr["course_code"].ToString() + "','" + dr["Message"].ToString() + "')"; SqlCommand oCmd = new SqlCommand(strSQL,oConn); oCmd.ExecuteNonQuery(); } oConn.Close(); //Display Transfer Result. if (stuResults.UpdateError.Rows.Count>0 ) lblError.Text = "Success (Y/N):" + stuResults.UpdateError.Rows[0][0] + " - " + stuResults.UpdateError.Rows[0][1]; else lblError.Text = "Success (Y/N):" + stuResults.StuChoiceUpdate.Rows[0][0] + " - " + stuResults.StuChoiceUpdate.Rows[0][1]; }
protected void btnUpGetStudentChoices_Click(object sender, EventArgs e) { com.maplewood.www.mwWebSrvStAc Integration = new com.maplewood.www.mwWebSrvStAc(); Integration.Url = strWebServiceURL; Integration.Timeout = 60000000; lblResultText.Text = btnUpGetStudentChoices.Text.ToString(); //Loop thru selected Schools foreach (ListItem itm in chkSchools.Items) { if (itm.Selected) { strSQL = "DELETE FROM MWStudentChoices WHERE Board_Code = " + CP.SQLClean(strBoardCode) + " AND School_Code = " + CP.SQLClean(itm.Value.ToString()); //Response.Write(strSQL); SqlConnection oConn = new SqlConnection(strCareerdbImportLocal); oConn.Open(); SqlDataAdapter oDA = new SqlDataAdapter(strSQL, oConn); DataTable dtb = new DataTable(); oDA.Fill(dtb); oConn.Close(); com.maplewood.www.StAc_StuChoice objMW = new com.maplewood.www.StAc_StuChoice(); objMW = Integration.GetStudentChoices(itm.Value.ToString(), ""); if (objMW.HasErrors) { Response.Write("<br />" + objMW.Errors.Rows.Count.ToString()); Response.Write(objMW.Errors[0].Error_Details.ToString()); } if (objMW.Student_Choice_Details.Count > 0) { strResults.Append(objMW.Student_Choice_Details.Count.ToString() + " : " + itm.Value.ToString() + ":" + itm.Text.ToString() + "\r\n"); strResults.Append("--------------------------------------" + "\r\n"); } SqlBulkCopy oBulk = new SqlBulkCopy(strCareerdbImportLocal); oBulk.BulkCopyTimeout = 120000; oBulk.DestinationTableName = "MWStudentChoices"; oBulk.WriteToServer(objMW.Student_Choice_Details); oBulk.Close(); //-------------------------- } } txtResults.Text = strResults.ToString(); }
protected void btnGetChoices_Click(object sender, EventArgs e) { //Get student choices done through our application //----------------------------------------------- string strSQL = "DELETE FROM MWStudentChoices"; SqlConnection oConn = new SqlConnection(strConn); oConn.Open(); SqlCommand oCmd = new SqlCommand(strSQL,oConn); oCmd.ExecuteNonQuery(); oConn.Close(); //------------------------------------------------ //Student Course Choices //-------------------------- com.maplewood.www.StAc_StuChoice objMW = new com.maplewood.www.StAc_StuChoice(); objMW = Integration.GetStudentChoices(ddlSchoolCode.SelectedValue.ToString(), ""); Response.Write("Course Choices Count: " + objMW.Student_Choice_Details.Count.ToString() + "<br/>"); grdStuChoices.DataSource = objMW.Student_Choice_Details; grdStuChoices.DataBind(); SqlBulkCopy oBulk = new SqlBulkCopy(strConn); oBulk.DestinationTableName = "MWStudentChoices"; oBulk.WriteToServer(objMW.Student_Choice_Details); oBulk.Close(); }
protected void btnUpExportToMaplewood_Click(object sender, EventArgs e) { lblResultText.Text = btnUpExportToMaplewood.Text.ToString(); txtResults.Text = ""; SqlConnection oConn = new SqlConnection(strCareerdbImportLocal); oConn.Open(); //Get parts of CC student choices based on ExportPart strSQL = String.Format(@"SELECT board_code, school_code, course_code, student_code, choice_type, choice_type_title FROM MWExport WHERE board_code = {0} AND school_code = {1} AND ExportPart = {2} order by board_code, school_code, student_code, choice_type, CourseDateAdded" , CP.SQLClean(strBoardCode), CP.SQLClean(ddlSchoolCode.SelectedValue.ToString()) , ddlExportPart.SelectedValue.ToString()); SqlDataAdapter oDA = new SqlDataAdapter(strSQL, oConn); DataTable dtb = new DataTable(); oDA.Fill(dtb); //Maplewood code to store all choices and then pass everythign together com.maplewood.www.StAc_StuChoice stuChoice = new com.maplewood.www.StAc_StuChoice(); int iCounter = 0; foreach (DataRow dr in dtb.Rows) { stuChoice.Student_Choices.AddStudent_ChoicesRow(iCounter); stuChoice.Student_Choice_Details.AddStudent_Choice_DetailsRow(dr["board_code"].ToString(), dr["school_code"].ToString(), dr["course_code"].ToString(), dr["student_code"].ToString(), dr["choice_type"].ToString(), dr["choice_type_title"].ToString(), stuChoice.Student_Choices[iCounter]); iCounter += 1; } //Call Update student choices and get errors com.maplewood.www.mwWebSrvStAc Integration = new com.maplewood.www.mwWebSrvStAc(); Integration.Url = strWebServiceURL; Integration.Timeout = 60000000; dtmTimeBefore = DateTime.Now; com.maplewood.www.StAc_StuChoiceUpdate stuResults; stuResults = Integration.UpdateStuChoices(ddlSchoolCode.SelectedValue.ToString(), "Y", "N", stuChoice); DataTable dtbErrors = stuResults.UpdateError; dtmTimeAfter = DateTime.Now; timDuration = (TimeSpan)dtmTimeAfter.Subtract(dtmTimeBefore); foreach (DataRow dr in dtbErrors.Rows) { if (dr["Message"].ToString() != "Student already has choice selected.") { strSQL = "INSERT INTO MWUploadErrors(SystemNameId, SchoolCode, StudentId, CourseCode, ErrorMessage)"; strSQL += "VALUES(" + strSystemNameID + ", '" + dr["school_code"].ToString() + "','"; strSQL += dr["student_code"].ToString() + "','" + dr["course_code"].ToString() + "',"; strSQL += CP.SQLClean(dr["Message"].ToString()) + ")"; SqlCommand oCmd = new SqlCommand(strSQL, oConn); oCmd.ExecuteNonQuery(); } } //Display Transfer Result. if (stuResults.UpdateError.Rows.Count > 0) txtResults.Text += "Success (Y/N) 1:" + stuResults.UpdateError.Rows[0][0] + " - " + stuResults.UpdateError.Rows[0][1] + "\n"; else txtResults.Text += "Success (Y/N) 2:" + stuResults.StuChoiceUpdate.Rows[0][0] + " - " + stuResults.StuChoiceUpdate.Rows[0][1] + "\n"; txtResults.Text += " - " + timDuration.Minutes.ToString() + ":" + timDuration.Seconds.ToString() + "\r\n"; oConn.Close(); }