protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string applicationID = Request.QueryString["ApplicationID"].ToString();

            //      ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Application Submitted Successfully !','0');", true);

            DatabaseFunctions db = new DatabaseFunctions();
            db.updateApplicationStatus_Submit(Convert.ToInt32(applicationID));

            DataSet appData = db.getApplication_ID((applicationID));
            if (appData != null)
            {
                int programID = Convert.ToInt32(appData.Tables[0].Rows[0]["ProgramID"].ToString());
                DataSet pDate = db.getProgramByID(programID);
                if (pDate.Tables[0].Rows.Count > 0)
                {
                    int instantadmission = Convert.ToInt16(pDate.Tables[0].Rows[0]["InstantAdmission"].ToString());
                    if (instantadmission == 1)
                    {
                        string programName = appData.Tables[0].Rows[0]["programName"].ToString();
                        string CourseName = appData.Tables[0].Rows[0]["Course1"].ToString();
                        string campus = appData.Tables[0].Rows[0]["Campus"].ToString();
                        string regno = appData.Tables[0].Rows[0]["formnumber"].ToString();

                        db.insertInstantAdmissiondata(regno, programName, CourseName, campus);
                        //db.AssignAcceptanceFee()
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup2", "alertNew('You have been successfully awarded admission !','0');", true);
                        DatabaseFunctions d = new DatabaseFunctions();
                        d.AssignAcceptanceFee(StudentID, programID, 0);
                        ///// Generate acceptance fee and send a message. 
                        d.InsertIntoStudentInfoTableNew(programID, "ND1", StudentID, 0, 1, "0", DateTime.Now.Year.ToString());
                        int BatchID = d.GetBatchID(DateTime.Now.Year.ToString());
                        string matricno=DateTime.Now.Year+"-"+programName+"-"+StudentID;
                        d.InsertIntoAddmissionTableNew(programID, StudentID, 0, "Merit", matricno, BatchID);
                        double AcceptanceFee = d.GetAcceptanceFeeForProgram(programID);
                        ///// Update Admission Status to 1 . 
                        ///// Insert Values to StudentInfo_tbl and AddmissionList (New One) 

                        if(AcceptanceFee!=-1)
                        {
                            string Message = "Acceptence Fee Of " +AcceptanceFee+ " Has Been Assigned to You <br> Please Submit This Fees with in One Week";
                            d.SendMessage(StudentID, Message, "Acceptance Fee", 0);
                        }

                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Application Submitted Successfully !','0');", true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "alertNew('Error Submiting Application!','1');", true);
        }
    }