protected void btnSave_Click(object sender, EventArgs e) { try { StudentBO objStudentBO = new StudentBO(); ApplicationResult objResults = new ApplicationResult(); StudentBL objStudentBL = new StudentBL(); StudentTBO objStudentTBO = new StudentTBO(); //if ((ddlSchoolName.SelectedItem.Text == "" || ddlSchoolName.SelectedItem.Text == "--Select--") // || (ddlSection.SelectedItem.Text == "" || ddlSection.SelectedItem.Text == "--Select--") // || (ddlClassName.SelectedItem.Text == "" || ddlClassName.SelectedItem.Text == "--Select--") // || (ddlDivisionName.SelectedItem.Text == "" || ddlDivisionName.SelectedItem.Text == "--Select--") // || (ddlYear.SelectedItem.Text == "" || ddlYear.SelectedItem.Text == "--Select--") // || (ddlStatus.SelectedItem.Text == "" || ddlStatus.SelectedItem.Text == "--Select--")) //{ DatabaseTransaction.OpenConnectionTransation(); for (int i = 0; i < gvExcelFile.Rows.Count; i++) { objStudentBO.SchoolMID = Convert.ToInt32(ddlSchoolName.SelectedValue); objStudentBO.StudentFirstNameEng = gvExcelFile.Rows[i].Cells[0].Text.Replace(" ", ""); objStudentBO.StudentFirstNameGuj = gvExcelFile.Rows[i].Cells[3].Text.Replace(" ", ""); objStudentBO.StudentMiddleNameEng = gvExcelFile.Rows[i].Cells[1].Text.Replace(" ", ""); objStudentBO.StudentMiddleNameGuj = gvExcelFile.Rows[i].Cells[4].Text.Replace(" ", ""); objStudentBO.StudentLastNameEng = gvExcelFile.Rows[i].Cells[2].Text.Replace(" ", ""); objStudentBO.StudentLastNameGuj = gvExcelFile.Rows[i].Cells[5].Text.Replace(" ", ""); objStudentBO.FatherFirstNameEng = gvExcelFile.Rows[i].Cells[6].Text.Replace(" ", ""); objStudentBO.FatherFirstNameGuj = gvExcelFile.Rows[i].Cells[9].Text.Replace(" ", ""); objStudentBO.FatherMiddleNameEng = gvExcelFile.Rows[i].Cells[7].Text.Replace(" ", ""); objStudentBO.FatherMiddleNameGuj = gvExcelFile.Rows[i].Cells[10].Text.Replace(" ", ""); objStudentBO.FatherLastNameEng = gvExcelFile.Rows[i].Cells[8].Text.Replace(" ", ""); objStudentBO.FatherLastNameGuj = gvExcelFile.Rows[i].Cells[11].Text.Replace(" ", ""); objStudentBO.MotherFirstNameEng = gvExcelFile.Rows[i].Cells[12].Text.Replace(" ", ""); objStudentBO.MotherFirstNameGuj = gvExcelFile.Rows[i].Cells[15].Text.Replace(" ", ""); objStudentBO.MotherMiddleNameEng = gvExcelFile.Rows[i].Cells[13].Text.Replace(" ", ""); objStudentBO.MotherMiddleNameGuj = gvExcelFile.Rows[i].Cells[16].Text.Replace(" ", ""); objStudentBO.MotherLastNameEng = gvExcelFile.Rows[i].Cells[14].Text.Replace(" ", ""); objStudentBO.MotherLastNameGuj = gvExcelFile.Rows[i].Cells[17].Text.Replace(" ", ""); objStudentBO.AdmissionNo = gvExcelFile.Rows[i].Cells[18].Text.Replace(" ", ""); objStudentBO.CurrentDate = gvExcelFile.Rows[i].Cells[19].Text.Replace(" ", ""); objStudentBO.CurrentYear = ddlYear.SelectedItem.ToString(); objStudentBO.CurrentSectionID = Convert.ToInt32(ddlSection.SelectedValue); objStudentBO.CurrentClassID = Convert.ToInt32(ddlClassName.SelectedValue); // objStudentBO.CurrentClassID = Convert.ToInt32(ddlClass.SelectedValue); objStudentBO.CurrentDivisionTID = Convert.ToInt32(ddlDivisionName.SelectedValue); objStudentBO.CurrentGrNo = gvExcelFile.Rows[i].Cells[20].Text.Replace(" ", ""); objStudentBO.AdmittedClassID = -1; objStudentBO.AdmittedDivisionTID = -1; objStudentBO.AdmittedYear = "-1"; objStudentBO.StudentPhoto = ImageToByteArrayFromFilePath("../Images/NoImage-big.jpg"); objStudentBO.GenderEng = gvExcelFile.Rows[i].Cells[22].Text; objStudentBO.GenderGuj = gvExcelFile.Rows[i].Cells[21].Text; //txtDateOfBirth.ReadOnly = false; objStudentBO.DateOfBirth = gvExcelFile.Rows[i].Cells[23].Text.Replace(" ", ""); //txtDateOfBirth.ReadOnly = true; objStudentBO.BirthDistrictEng = gvExcelFile.Rows[i].Cells[24].Text.Replace(" ", ""); objStudentBO.BirthDistrictGuj = gvExcelFile.Rows[i].Cells[25].Text.Replace(" ", ""); objStudentBO.NationalityEng = gvExcelFile.Rows[i].Cells[26].Text.Replace(" ", ""); objStudentBO.NationalityGuj = gvExcelFile.Rows[i].Cells[27].Text.Replace(" ", ""); objStudentBO.ReligionEng = gvExcelFile.Rows[i].Cells[28].Text.Replace(" ", ""); objStudentBO.CasteEng = gvExcelFile.Rows[i].Cells[29].Text.Replace(" ", ""); objStudentBO.CasteGuj = gvExcelFile.Rows[i].Cells[30].Text.Replace(" ", ""); objStudentBO.SubCasteEng = gvExcelFile.Rows[i].Cells[31].Text.Replace(" ", ""); objStudentBO.SubCasteGuj = gvExcelFile.Rows[i].Cells[32].Text.Replace(" ", ""); objStudentBO.CategoryEng = gvExcelFile.Rows[i].Cells[33].Text.Replace(" ", ""); objStudentBO.CategoryGuj = gvExcelFile.Rows[i].Cells[34].Text.Replace(" ", ""); objStudentBO.SubCategory = ""; objStudentBO.HandicapPrecent = gvExcelFile.Rows[i].Cells[35].Text.Replace(" ", ""); objStudentBO.OtherDefect = gvExcelFile.Rows[i].Cells[36].Text.Replace(" ", ""); objStudentBO.PresentAddressEng = gvExcelFile.Rows[i].Cells[37].Text.Replace(" ", ""); objStudentBO.PresentAddressGuj = gvExcelFile.Rows[i].Cells[38].Text.Replace(" ", ""); objStudentBO.PresentCityEng = gvExcelFile.Rows[i].Cells[39].Text.Replace(" ", ""); objStudentBO.PresentCityGuj = gvExcelFile.Rows[i].Cells[40].Text.Replace(" ", ""); objStudentBO.PresentStateEng = gvExcelFile.Rows[i].Cells[41].Text.Replace(" ", ""); objStudentBO.PresentStateGuj = gvExcelFile.Rows[i].Cells[42].Text.Replace(" ", ""); objStudentBO.PresentPinCode = gvExcelFile.Rows[i].Cells[43].Text.Replace(" ", ""); objStudentBO.PresentContactNo = gvExcelFile.Rows[i].Cells[44].Text.Replace(" ", ""); objStudentBO.PresentEmailId = ""; objStudentBO.PermanentAddressEng = gvExcelFile.Rows[i].Cells[45].Text.Replace(" ", ""); objStudentBO.PermanentAddressGuj = gvExcelFile.Rows[i].Cells[46].Text.Replace(" ", ""); objStudentBO.PermanentCityEng = gvExcelFile.Rows[i].Cells[47].Text.Replace(" ", ""); objStudentBO.PermanentCityGuj = gvExcelFile.Rows[i].Cells[48].Text.Replace(" ", ""); objStudentBO.PermanentStateEng = gvExcelFile.Rows[i].Cells[49].Text.Replace(" ", ""); objStudentBO.PermanentStateGuj = gvExcelFile.Rows[i].Cells[50].Text.Replace(" ", ""); objStudentBO.PermanentPinCode = gvExcelFile.Rows[i].Cells[51].Text.Replace(" ", ""); objStudentBO.PermanentContactNo = gvExcelFile.Rows[i].Cells[52].Text.Replace(" ", ""); objStudentBO.PermanentEmailId = ""; objStudentBO.FatherOccupation = gvExcelFile.Rows[i].Cells[53].Text.Replace(" ", ""); objStudentBO.MotherOccupation = gvExcelFile.Rows[i].Cells[54].Text.Replace(" ", ""); objStudentBO.GardianOccupation = gvExcelFile.Rows[i].Cells[55].Text.Replace(" ", ""); objStudentBO.FatherQualification = gvExcelFile.Rows[i].Cells[56].Text.Replace(" ", ""); objStudentBO.MotherQualification = gvExcelFile.Rows[i].Cells[57].Text.Replace(" ", ""); objStudentBO.GardianQualification = gvExcelFile.Rows[i].Cells[58].Text.Replace(" ", ""); objStudentBO.FatherMobileNo = gvExcelFile.Rows[i].Cells[59].Text.Replace(" ", ""); objStudentBO.MotherMobileNo = gvExcelFile.Rows[i].Cells[60].Text.Replace(" ", ""); objStudentBO.GardianMobileNo = gvExcelFile.Rows[i].Cells[61].Text.Replace(" ", ""); objStudentBO.FatherEmailID = gvExcelFile.Rows[i].Cells[62].Text.Replace(" ", ""); objStudentBO.MotherEmailID = gvExcelFile.Rows[i].Cells[63].Text.Replace(" ", ""); objStudentBO.GardianEmailID = gvExcelFile.Rows[i].Cells[64].Text.Replace(" ", ""); objStudentBO.Height = ""; objStudentBO.Wight = ""; objStudentBO.Hobbies = ""; objStudentBO.StatusMasterID = Convert.ToInt32(ddlStatus.SelectedValue); objStudentBO.LeftDate = ""; objStudentBO.LeftReason = ""; objStudentBO.LeftYear = "-Select-"; objStudentBO.LeftStd = ""; objStudentBO.LcNo = ""; objStudentBO.LcDate = ""; objStudentBO.LcRemarks = ""; objStudentBO.LcCopy = ""; objStudentBO.RegisteredYear = "-Select-"; objStudentBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objStudentBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objStudentBO.AdmissionDate = ""; #region RollBack Transaction Starts if (ViewState["Mode"].ToString() == "Save") { objResults = objStudentBL.Student_Insert(objStudentBO); if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { ViewState["StudentMID"] = Convert.ToInt32(objResults.resultDT.Rows[0][0].ToString()); } objStudentTBO.StudentMID = Convert.ToInt32(ViewState["StudentMID"].ToString()); objStudentTBO.ClassMID = Convert.ToInt32(ddlClassName.SelectedValue); objStudentTBO.Year = ddlYear.SelectedItem.ToString(); objStudentTBO.DivisionTID = Convert.ToInt32(ddlDivisionName.SelectedValue); objStudentTBO.StatusMasterID = Convert.ToInt32(ddlStatus.SelectedValue); objStudentTBO.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString(); objStudentTBO.StatusName = ddlStatus.SelectedItem.ToString(); objStudentTBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objStudentTBO.GrNo = objStudentBO.CurrentGrNo; objResults = objStudentBL.StudentT_Insert(objStudentTBO); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { // Response.Redirect("StudentDataImport.aspx"); } else { ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Student GRNo Already Exist.');", true); ClearAll(); } } } } ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Record Saved Successfully.');", true); string Extension = string.Empty; Extension = Path.GetExtension(FileUpload1.FileName); System.IO.File.Delete(Server.MapPath("../_ImportData/" + ddlSchoolName.SelectedItem.Text.Replace(" ", "").ToString() + Extension)); #endregion ClearAll(); DatabaseTransaction.CommitTransation(); //} //else //{ // ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Select Every Dropdown.');", true); //} } catch (Exception ex) { DatabaseTransaction.RollbackTransation(); string Extension = string.Empty; Extension = Path.GetExtension(FileUpload1.FileName); System.IO.File.Delete(Server.MapPath("../_ImportData/" + ddlSchoolName.SelectedItem.Text.Replace(" ", "").ToString() + Extension)); ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Oops!Contact to your Administrator.');", true); } }
protected void btnSave_Click(object sender, EventArgs e) { try { DatabaseTransaction.OpenConnectionTransation(); int intCount = 0; int intgvRowCount = gvStudent.Rows.Count; foreach (GridViewRow row in gvStudent.Rows) { ViewState["ClassMID"] = Convert.ToInt32(Request.Form[ddlClass.UniqueID]); ViewState["DivisionName"] = Convert.ToInt32(Request.Form[ddlDivision.UniqueID]); ViewState["AcademicYear"] = ddlAcademicYear.SelectedItem.ToString(); ViewState["StudentMID"] = Convert.ToInt32(row.Cells[0].Text); ViewState["StudentTID"] = Convert.ToInt32(row.Cells[1].Text); StudentBL objStudentBL = new StudentBL(); StudentTBO objStudentTBO = new StudentTBO(); ApplicationResult objResults = new ApplicationResult(); DropDownList ddlgridDivision = (DropDownList)row.Cells[6].FindControl("ddlGridDivision"); if (((CheckBox)row.FindControl("chkChild")).Checked) { if (ddlgridDivision.SelectedValue != "") { if (ViewState["DivisionName"].ToString() == ddlgridDivision.SelectedValue) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Student are not upgrade into the Same Class.');</script>"); } else { objResults = objStudentBL.StudentM_Update_AtTimeOfDivisionTransfer(Convert.ToInt32(ViewState["StudentMID"].ToString()), Convert.ToInt32(ddlgridDivision.SelectedValue), Convert.ToInt32(Session[ApplicationSession.USERID]), DateTime.UtcNow.AddHours(5.5).ToString()); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { } objStudentTBO.StudentTID = Convert.ToInt32(ViewState["StudentTID"].ToString()); objResults = objStudentBL.StudentT_Update_AtTimeOfDivisionTransfer(Convert.ToInt32(ViewState["StudentTID"].ToString()), Convert.ToInt32(ddlgridDivision.SelectedValue), Convert.ToInt32(Session[ApplicationSession.USERID]), DateTime.UtcNow.AddHours(5.5).ToString()); if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Students Division Transfered Successfully.');</script>"); } } } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Division(s) are not Selected.');</script>"); } } else { intCount++; } } if (intgvRowCount == intCount) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Please Select Atleast One Student.');$('#divLoading').hide();</script>"); } else { gvStudent.Visible = false; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "BindSection();", true); } DatabaseTransaction.CommitTransation(); } catch (Exception ex) { DatabaseTransaction.RollbackTransation(); logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }