Esempio n. 1
0
        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("&nbsp;", "");
                    objStudentBO.StudentFirstNameGuj  = gvExcelFile.Rows[i].Cells[3].Text.Replace("&nbsp;", "");
                    objStudentBO.StudentMiddleNameEng = gvExcelFile.Rows[i].Cells[1].Text.Replace("&nbsp;", "");
                    objStudentBO.StudentMiddleNameGuj = gvExcelFile.Rows[i].Cells[4].Text.Replace("&nbsp;", "");
                    objStudentBO.StudentLastNameEng   = gvExcelFile.Rows[i].Cells[2].Text.Replace("&nbsp;", "");
                    objStudentBO.StudentLastNameGuj   = gvExcelFile.Rows[i].Cells[5].Text.Replace("&nbsp;", "");

                    objStudentBO.FatherFirstNameEng  = gvExcelFile.Rows[i].Cells[6].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherFirstNameGuj  = gvExcelFile.Rows[i].Cells[9].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherMiddleNameEng = gvExcelFile.Rows[i].Cells[7].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherMiddleNameGuj = gvExcelFile.Rows[i].Cells[10].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherLastNameEng   = gvExcelFile.Rows[i].Cells[8].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherLastNameGuj   = gvExcelFile.Rows[i].Cells[11].Text.Replace("&nbsp;", "");

                    objStudentBO.MotherFirstNameEng  = gvExcelFile.Rows[i].Cells[12].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherFirstNameGuj  = gvExcelFile.Rows[i].Cells[15].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherMiddleNameEng = gvExcelFile.Rows[i].Cells[13].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherMiddleNameGuj = gvExcelFile.Rows[i].Cells[16].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherLastNameEng   = gvExcelFile.Rows[i].Cells[14].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherLastNameGuj   = gvExcelFile.Rows[i].Cells[17].Text.Replace("&nbsp;", "");

                    objStudentBO.AdmissionNo      = gvExcelFile.Rows[i].Cells[18].Text.Replace("&nbsp;", "");
                    objStudentBO.CurrentDate      = gvExcelFile.Rows[i].Cells[19].Text.Replace("&nbsp;", "");
                    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("&nbsp;", "");

                    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("&nbsp;", "");
                    //txtDateOfBirth.ReadOnly = true;
                    objStudentBO.BirthDistrictEng     = gvExcelFile.Rows[i].Cells[24].Text.Replace("&nbsp;", "");
                    objStudentBO.BirthDistrictGuj     = gvExcelFile.Rows[i].Cells[25].Text.Replace("&nbsp;", "");
                    objStudentBO.NationalityEng       = gvExcelFile.Rows[i].Cells[26].Text.Replace("&nbsp;", "");
                    objStudentBO.NationalityGuj       = gvExcelFile.Rows[i].Cells[27].Text.Replace("&nbsp;", "");
                    objStudentBO.ReligionEng          = gvExcelFile.Rows[i].Cells[28].Text.Replace("&nbsp;", "");
                    objStudentBO.CasteEng             = gvExcelFile.Rows[i].Cells[29].Text.Replace("&nbsp;", "");
                    objStudentBO.CasteGuj             = gvExcelFile.Rows[i].Cells[30].Text.Replace("&nbsp;", "");
                    objStudentBO.SubCasteEng          = gvExcelFile.Rows[i].Cells[31].Text.Replace("&nbsp;", "");
                    objStudentBO.SubCasteGuj          = gvExcelFile.Rows[i].Cells[32].Text.Replace("&nbsp;", "");
                    objStudentBO.CategoryEng          = gvExcelFile.Rows[i].Cells[33].Text.Replace("&nbsp;", "");
                    objStudentBO.CategoryGuj          = gvExcelFile.Rows[i].Cells[34].Text.Replace("&nbsp;", "");
                    objStudentBO.SubCategory          = "";
                    objStudentBO.HandicapPrecent      = gvExcelFile.Rows[i].Cells[35].Text.Replace("&nbsp;", "");
                    objStudentBO.OtherDefect          = gvExcelFile.Rows[i].Cells[36].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentAddressEng    = gvExcelFile.Rows[i].Cells[37].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentAddressGuj    = gvExcelFile.Rows[i].Cells[38].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentCityEng       = gvExcelFile.Rows[i].Cells[39].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentCityGuj       = gvExcelFile.Rows[i].Cells[40].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentStateEng      = gvExcelFile.Rows[i].Cells[41].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentStateGuj      = gvExcelFile.Rows[i].Cells[42].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentPinCode       = gvExcelFile.Rows[i].Cells[43].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentContactNo     = gvExcelFile.Rows[i].Cells[44].Text.Replace("&nbsp;", "");
                    objStudentBO.PresentEmailId       = "";
                    objStudentBO.PermanentAddressEng  = gvExcelFile.Rows[i].Cells[45].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentAddressGuj  = gvExcelFile.Rows[i].Cells[46].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentCityEng     = gvExcelFile.Rows[i].Cells[47].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentCityGuj     = gvExcelFile.Rows[i].Cells[48].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentStateEng    = gvExcelFile.Rows[i].Cells[49].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentStateGuj    = gvExcelFile.Rows[i].Cells[50].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentPinCode     = gvExcelFile.Rows[i].Cells[51].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentContactNo   = gvExcelFile.Rows[i].Cells[52].Text.Replace("&nbsp;", "");
                    objStudentBO.PermanentEmailId     = "";
                    objStudentBO.FatherOccupation     = gvExcelFile.Rows[i].Cells[53].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherOccupation     = gvExcelFile.Rows[i].Cells[54].Text.Replace("&nbsp;", "");
                    objStudentBO.GardianOccupation    = gvExcelFile.Rows[i].Cells[55].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherQualification  = gvExcelFile.Rows[i].Cells[56].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherQualification  = gvExcelFile.Rows[i].Cells[57].Text.Replace("&nbsp;", "");
                    objStudentBO.GardianQualification = gvExcelFile.Rows[i].Cells[58].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherMobileNo       = gvExcelFile.Rows[i].Cells[59].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherMobileNo       = gvExcelFile.Rows[i].Cells[60].Text.Replace("&nbsp;", "");
                    objStudentBO.GardianMobileNo      = gvExcelFile.Rows[i].Cells[61].Text.Replace("&nbsp;", "");
                    objStudentBO.FatherEmailID        = gvExcelFile.Rows[i].Cells[62].Text.Replace("&nbsp;", "");
                    objStudentBO.MotherEmailID        = gvExcelFile.Rows[i].Cells[63].Text.Replace("&nbsp;", "");
                    objStudentBO.GardianEmailID       = gvExcelFile.Rows[i].Cells[64].Text.Replace("&nbsp;", "");
                    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);
            }
        }
Esempio n. 2
0
        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>");
            }
        }