protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { try { DTOStudentRegistration tostud = new DTOStudentRegistration(); tostud.Address = txtStudentAddress.Text; tostud.BranchId = int.Parse(ddlClass.SelectedValue); tostud.DOB = DateTime.Parse(txtDOB.Text); tostud.FatherName = txtFatherName.Text; tostud.InstituteId = int.Parse(Session["InstituteID"].ToString()); tostud.MotherName = txtMotherName.Text; tostud.ParentsMobileNo = txtParentsContactNumber.Text; tostud.ParentsEmail = txtParentsEmail.Text; tostud.RollNo = txtRollNo.Text; if (Session["InstituteType"].ToString() == "S") { tostud.SemesterId = 0; } else { tostud.SemesterId = int.Parse(ddlSemester.SelectedValue); } tostud.StudentName = txtStudentName.Text; tostud.Gender = ddlGender.SelectedValue; if (new BOStudentRegistration().SaveStudentDetails(tostud)) { //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Record inserted';var elem = document.createElement('img');elem.setAttribute('src', 'tick.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Green';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Student Details Saved Sucessfully', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); #region SMS string _messageTemplate = new BOSms().GetSMSTemplate("NEWSTUDENTADDED"); C2CSMS.SendSMS(_messageTemplate.Replace("##STUDENTNAME##", tostud.StudentName).Replace("##InstituteName##", Session["InstituteName"].ToString()), tostud.ParentsMobileNo); #endregion #region E-Mail //Send mail if (!string.IsNullOrEmpty(tostud.ParentsEmail)) { string s_subject = "Information From Campus2Caretaker"; string s_msg = String.Concat("Greetings from Campus2Caretaker.", Environment.NewLine, Environment.NewLine, _messageTemplate.Replace("##STUDENTNAME##", tostud.StudentName).Replace("##InstituteName##", Session["InstituteName"].ToString())) + Environment.NewLine + Environment.NewLine; C2CEmail.SendC2CMail(s_msg, s_subject, string.Empty, tostud.ParentsEmail, null, null); } #endregion clear(); RefreshGridView(); } else { //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Error';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Red';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Error', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } } catch { } } }
protected void btnUpload_Click(object sender, EventArgs e) { try { if (FlUploadcsv.HasFile) { string FileName = FlUploadcsv.FileName; if (FlUploadcsv.PostedFile.ContentType == "application/vnd.ms-excel" || FlUploadcsv.PostedFile.ContentType == "application/excel" || FlUploadcsv.PostedFile.ContentType == "application/x-msexcel" || FlUploadcsv.PostedFile.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" //this is xlsx format ) { string path = string.Concat(Server.MapPath("~/Documents/" + FlUploadcsv.FileName)); FlUploadcsv.PostedFile.SaveAs(path); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("StudentName", typeof(string)); dt.Columns.Add("LastName", typeof(string)); dt.Columns.Add("FatherName", typeof(string)); dt.Columns.Add("MotherName", typeof(string)); dt.Columns.Add("DateOfBirth", typeof(DateTime)); dt.Columns.Add("Semester", typeof(string)); dt.Columns.Add("Branch", typeof(string)); dt.Columns.Add("Section", typeof(string)); dt.Columns.Add("RollNo", typeof(string)); dt.Columns.Add("ParentsMobileNo", typeof(string)); dt.Columns.Add("StudentAddress", typeof(string)); dt.Columns.Add("Gender", typeof(string)); dt.Columns.Add("ParentsEmail", typeof(string)); bool isValidExcelSheet = CheckExcelSheet(FileName, dt); if (isValidExcelSheet) { if (new BOStudentRegistration().SaveStudentRegistrationExcel(dt, Session["InstituteID"].ToString())) { string _messageTemplate = new BOSms().GetSMSTemplate("NEWSTUDENTADDED"); #region SMS for (int i = 0; i < dt.Rows.Count; i++) { C2CSMS.SendSMS(_messageTemplate.Replace("##STUDENTNAME##", dt.Rows[i][0].ToString()).Replace("##InstituteName##", Session["InstituteName"].ToString()), dt.Rows[i][9].ToString()); } #endregion #region E-Mail for (int i = 0; i < dt.Rows.Count; i++) { //Send mail if (!string.IsNullOrEmpty(dt.Rows[i][12].ToString())) { string s_subject = "Information From Campus2Caretaker"; string s_msg = String.Concat("Greetings from Campus2Caretaker.", _messageTemplate.Replace("##STUDENTNAME##", dt.Rows[i][0].ToString()).Replace("##InstituteName##", Session["InstituteName"].ToString())) + Environment.NewLine + Environment.NewLine; C2CEmail.SendC2CMail(s_msg, s_subject, string.Empty, dt.Rows[i][12].ToString(), null, null); } } #endregion //string script = @"document.getElementById('" + dvUploadStatus.ClientID + "').innerHTML='Excel uploaded successfully..';var elem = document.createElement('img');elem.setAttribute('src', 'tick.jpg');document.getElementById('" + dvUploadStatus.ClientID + "').appendChild(elem);document.getElementById('" + dvUploadStatus.ClientID + "').style.color = 'Green';document.getElementById('" + dvUploadStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + dvUploadStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + dvUploadStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Excel Uploaded Successfully', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } else { //string script = @"document.getElementById('" + dvUploadStatus.ClientID + "').innerHTML='Error in saving Excel!!';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + dvUploadStatus.ClientID + "').appendChild(elem);document.getElementById('" + dvUploadStatus.ClientID + "').style.color = 'Red';document.getElementById('" + dvUploadStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + dvUploadStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + dvUploadStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Error in saving Excel', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); System.IO.File.Delete(Server.MapPath("~/Documents/").Replace("\\", "/") + FileName); } } else { System.IO.File.Delete(Server.MapPath("~/Documents/").Replace("\\", "/") + FileName); } } else { //string script = @"document.getElementById('" + dvUploadStatus.ClientID + "').innerHTML='Please select a valid excel file';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + dvUploadStatus.ClientID + "').appendChild(elem);document.getElementById('" + dvUploadStatus.ClientID + "').style.color = 'Red';document.getElementById('" + dvUploadStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + dvUploadStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + dvUploadStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Please Select a Valid Excel File', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } } else { //string script = @"document.getElementById('" + dvUploadStatus.ClientID + "').innerHTML='Please select the excel file';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + dvUploadStatus.ClientID + "').appendChild(elem);document.getElementById('" + dvUploadStatus.ClientID + "').style.color = 'Red';document.getElementById('" + dvUploadStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + dvUploadStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + dvUploadStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Please Select Excel File', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } } catch { } }
protected void btnSaveInternals_Click(object sender, EventArgs e) { for (int index = 0; index < gvInternals.Rows.Count - 1; index++) { if (int.Parse(((TextBox)gvInternals.Rows[index].FindControl("txtMarksScored")).Text) > 0) { DTOInternals toInt = new DTOInternals(); toInt.BranchId = int.Parse(ddlClass.SelectedValue); if (Session["InstituteType"].ToString() == "S") { toInt.SemesterId = 0; } else { toInt.SemesterId = int.Parse(ddlSemester.SelectedValue); } toInt.Month = ddlMonth.SelectedValue; toInt.Year = ddlYear.SelectedValue; toInt.SubjectId = int.Parse(ddlSubjects.SelectedValue); toInt.Description = txtDescription.Text; Label lblStudentID = (Label)gvInternals.Rows[index].FindControl("lblStudentID"); Label lblStudentName = (Label)gvInternals.Rows[index].FindControl("lblStudentName"); TextBox txtMaxMarks = (TextBox)gvInternals.Rows[index].FindControl("txtMaxMarks"); TextBox txtMinMarks = (TextBox)gvInternals.Rows[index].FindControl("txtMinMarks"); TextBox txtMarksScored = (TextBox)gvInternals.Rows[index].FindControl("txtMarksScored"); TextBox txtReMarks = (TextBox)gvInternals.Rows[index].FindControl("txtRemarks"); toInt.InstituteId = int.Parse(Session["InstituteID"].ToString()); toInt.MarksScored = decimal.Parse(txtMarksScored.Text); toInt.MaxMarks = decimal.Parse(txtMaxMarks.Text); toInt.MinMarks = decimal.Parse(txtMinMarks.Text); toInt.StudentId = int.Parse(lblStudentID.Text); toInt.Remarks = txtReMarks.Text; DTOStudentRegistration tostu = new DTOStudentRegistration(); tostu.StudentId = int.Parse(lblStudentID.Text); DataTable dtStudDet = new BOStudentRegistration().GetStudentDetails(tostu); if (new BOInternals().SaveUpdateInternals(toInt)) { #region SMS string _messageTemplate = new BOSms().GetSMSTemplate("INTERNALMARKSINTIMATION"); C2CSMS.SendSMS(_messageTemplate.Replace("##STUDENTNAME##", dtStudDet.Rows[0][0].ToString()).Replace("##INTERNALSMARKS##", String.Concat(toInt.MarksScored, " Out of ", toInt.MaxMarks)).Replace("##SUBJECTNAME##", ddlSubjects.SelectedItem.Text).Replace("##MONTHYEAR##", String.Concat(ddlMonth.SelectedItem.Text, string.Empty, ddlYear.SelectedItem.Text)).Replace("##InstituteName##", Session["InstituteName"].ToString()), dtStudDet.Rows[0][9].ToString()); #endregion #region E-Mail //Send mail if (!string.IsNullOrEmpty(dtStudDet.Rows[0][12].ToString())) { string s_subject = "Information From Campus2Caretaker"; string s_msg = String.Concat("Greetings from Campus2Caretaker.", Environment.NewLine, Environment.NewLine, _messageTemplate.Replace("##STUDENTNAME##", dtStudDet.Rows[0][0].ToString()).Replace("##INTERNALSMARKS##", String.Concat(toInt.MarksScored, " Out of ", toInt.MaxMarks)).Replace("##SUBJECTNAME##", ddlSubjects.SelectedItem.Text).Replace("##MONTHYEAR##", String.Concat(ddlMonth.SelectedItem.Text, string.Empty, ddlYear.SelectedItem.Text)).Replace("##InstituteName##", Session["InstituteName"].ToString())) + Environment.NewLine + Environment.NewLine; C2CEmail.SendC2CMail(s_msg, s_subject, string.Empty, dtStudDet.Rows[0][12].ToString(), null, null); } #endregion //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Record updated';var elem = document.createElement('img');elem.setAttribute('src', 'tick.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Green';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Internals Details Saved Successfully', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } else { //string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='Error';var elem = document.createElement('img');elem.setAttribute('src', 'cross.jpg');document.getElementById('" + divStatus.ClientID + "').appendChild(elem);document.getElementById('" + divStatus.ClientID + "').style.color = 'Red';document.getElementById('" + divStatus.ClientID + "').style.fontSize = '1em' ;document.getElementById('" + divStatus.ClientID + "').style.fontWeight = 'bold' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},4500);"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", script, true); string alertScript = "jAlert('Error', 'Campus2Caretaker');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript", alertScript, true); } } } clear(); }