private void btnSave_Click(object sender, EventArgs e)
        {
            studentInfo st_Info = new studentInfo();
            int count = st_Info.getTemCount();
            frmMain frm_M = new frmMain();
            frmStudentRegistation frm_Reg = new frmStudentRegistation();

            try
            {
                if (st_Info.add_StudentData() && st_Info.delete_TempData())
                {
                    DialogResult dResult = MessageBox.Show("Records added successfully.", systemMessage.MESSAGEBOXTITLE_SUCCESS, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (dResult == DialogResult.OK)
                    {

                        frmStuden_Details frm_Stdetail = new frmStuden_Details();

                        frmMain frm_M1 = new frmMain();
                        frm_Stdetail.MdiParent = frm_M1;
                        frm_M1.mainPanel.Controls.Clear();
                        frm_M1.mainPanel.Controls.Add(frm_Stdetail);
                        frm_M1.mainPanel.Dock = DockStyle.Fill;
                        frm_Stdetail.Show();
                        this.Close();
                        fill_DataGried();

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void setStudentId()
        {
            studentInfo stInfo = null;

            try
            {
                if (globleVeriables.STU_ID == 0)
                {
                    stInfo = new studentInfo();
                    int x = 0;
                    int tot = 0;

                    int i   = globleVeriables.STU_ID;

                    x = stInfo.getLastStID();

                    if (x == -1)
                    {
                        globleVeriables.STU_ID =  1;
                        txtStudentId.Text = globleVeriables.STU_ID.ToString();
                    }
                    else
                    {
                    tot = (x+1);
                    txtStudentId.Text = tot.ToString();
                    globleVeriables.STU_ID = tot;
                    }
                }

                else if (globleVeriables.STU_ID > 0)
                {
                    int y = 0;
                    int tot2 = 0;
                    y = globleVeriables.STU_ID;
                    tot2 = y+ 1;
                    txtStudentId.Text = tot2.ToString();
                    globleVeriables.STU_ID = tot2;
                }

            }
            catch (SqlException ex)
            {
                globleVeriables.STU_ID = globleVeriables.STU_ID - 1;
                if (ex.Message.Equals("Database Not Found!"))
                {
                    MessageBox.Show(systemMessage.DATABASE_NOTFOUND, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(systemMessage.TABLE_FAILED, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            globleVeriables.STU_ID = 0;
            studentInfo st_Info = new studentInfo ();
            int count = st_Info.getTemCount();

            if (count > 0)
            {

                DialogResult dialogResult = MessageBox.Show(systemMessage.EXIT_APP, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                if (dialogResult == DialogResult.OK)
                {

                    try
                    {
                        if (st_Info.add_StudentData()&& st_Info.delete_TempData())
                        {
                            DialogResult dResult = MessageBox.Show(+count+"  "+"Records add to view successfully.", systemMessage.MESSAGEBOXTITLE_SUCCESS, MessageBoxButtons.OK, MessageBoxIcon.Information);

                            if (dResult == DialogResult.OK)
                            {
                                Application.Exit(); ;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                Application.Exit();
            }
        }
        public void fill_DataGried()
        {
            studentInfo st_Info = null;
            DataSet ds = null;

            try
            {
                st_Info = new studentInfo();
                ds = new DataSet();

                ds = st_Info.getAllTepDataDorDataGride();

                this.gdvStudentDetails.DataSource = ds;
                this.gdvStudentDetails.DataMember = "student_Data";
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ds.Dispose();
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            studentBean stBean              = null;
            studentInfo stInfo = null;

            if (valid_control())
            {
                try
                {
                    stBean = new studentBean();
                    stInfo = new studentInfo();

                    stBean.Studentid = Int32.Parse(this.txtStudentId.Text.ToString().Trim());
                    stBean.St_name = this.txtStudentName.Text.Trim();
                    stBean.Dob = DateTime.Parse(this.dtpDOB.Text.Trim());
                    stBean.St_gradepointavg = Decimal.Parse(this.txtGradeAvg.Text.Trim());

                    if (this.cbTrue.Checked)
                    {
                        stBean.St_active = "Yes";
                    }
                    else
                    {
                        stBean.St_active = "No";
                    }

                    if (stInfo.add_TemStudentData(stBean))
                    {
                        MessageBox.Show(systemMessage.TEMP_SAVE, systemMessage.MESSAGEBOXTITLE_SUCCESS, MessageBoxButtons.OK, MessageBoxIcon.Information);

                        frmStuden_Details frm_Stdetail = new frmStuden_Details();
                        globleVeriables.STU_ID = globleVeriables.STU_ID - 1;

                        frmMain frm_M = new frmMain();
                        frm_Stdetail.MdiParent = frm_M;
                        frm_M.mainPanel.Controls.Clear();
                        frm_M.mainPanel.Controls.Add(frm_Stdetail);
                        frm_M.mainPanel.Dock = DockStyle.Fill;

                        frm_Stdetail.Show();
                        // Close form
                        this.Dispose();

                    }
                    else
                    {
                        MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    globleVeriables.STU_ID = globleVeriables.STU_ID - 1;
                    if (ex.Message.Equals("Database Not Found!"))
                    {
                        MessageBox.Show(systemMessage.DATABASE_NOTFOUND, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                clear_Content();
                setStudentId();
            }
        }