protected void signup_Click(object sender, EventArgs e)
    {
        main_class m = new main_class();

        //check
        string check = string.Format("select * from professor where username = '******' ",Profesor_usrname.Text);
        DataTable dt = m.filldt(check);

        if (dt.Rows.Count != 0)
        {
            exists.Visible = true;
        }
        else
        {
            int id = m.get_maxid("professor");

            string professor_register = string.Format("insert into professor (professor_Id,FName,Email,Contactno,Username,Password,approved,institute) values  ({0},'{1}','{2}',{3},'{4}','{5}' , 'No' , '{6}') ",
                id,
                Profesor_name.Text,
                Profesor_email.Text,
                Profesor_no.Text,
                Profesor_usrname.Text,
                Profesor_passwrd.Text,
                institute.Text);
            m.insertvalues(professor_register);

            //dispose
            m.cn.Close();
            m = null;

            Response.Redirect("Professor_login.aspx");

        }
    }
    protected void fill_Click(object sender, EventArgs e)
    {
        string professor = Session["Professor_Username"].ToString();
        main_class m = new main_class();

        for (int i = 0; i < attendence.Rows.Count; i++)
        {
            string result = "";
                RadioButtonList rb = attendence.Rows[i].Cells[4].FindControl("rblist") as RadioButtonList;
                if (rb.Items[0].Selected == true)
                {
                    result = "Present";
                }
                if (rb.Items[1].Selected == true)
                {
                    result = "Absent";
                }

            int max_id=m.get_maxid("attendence");
            string ins_attn = string.Format("insert into attendence values ({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8}) ",
                max_id,
                attendence.Rows[i].Cells[0].Text,
                attendence.Rows[i].Cells[1].Text,
                attendence.Rows[i].Cells[2].Text,
                result,
                professor,
                date.Text.ToString(),
                subject.Text,
                attendence.Rows[i].Cells[3].Text);
            m.insertvalues(ins_attn);
        }
    }
    protected void add_Click(object sender, EventArgs e)
    {
        string admin= Session["User"].ToString();

        main_class m = new main_class();

        int max_id = m.get_maxid("Department");
        string ins = string.Format("insert into department values ({0},'{1}','{2}') ",max_id,department.Text,admin);
        m.insertvalues(ins);

        bind_files();
    }
    protected void Upload_doc_Click(object sender, EventArgs e)
    {
        string professor = Session["Professor_Username"].ToString();
        main_class m = new main_class();
            if (FileUpload1.HasFile)
            {
                string ext = Path.GetExtension(FileUpload1.FileName);
                if (ext == ".PPTX" || ext == ".pptx" || ext == ".PPT" || ext == ".ppt" || ext == ".pdf" || ext == ".PDF" || ext == ".txt" || ext == ".TXT" || ext == ".DOC" || ext == ".doc" || ext == ".DOCX" || ext == ".docx")
                {
                    string q = "/Docs/" + FileUpload1.FileName;
                    FileUpload1.SaveAs(MapPath(q));

                    int max_id = m.get_maxid("docs");
                    //Inserting in db
                    string q1 = string.Format("insert into docs values ({0},'{1}','{2}','{3}') ", max_id, professor, q, doc_title.Text);
                    m.insertvalues(q1);
                    Response.Write("File Uploaded");

                    bind_files();
                }
                else
                {
                    Response.Write("Only PDF Files allowed");
                }
            }
    }
    protected void Upload_Image_Click(object sender, EventArgs e)
    {
        string User = Session["admin"].ToString();

        if (User == null || User == string.Empty)
        {
            Response.Redirect("Admin_Login.aspx");
        }
        else
        {

            string cat = "hello";
            main_class m = new main_class();

            //file upload code
            if (FileUpload1.HasFile)
            {

                    string q = "/images/PhotoGallery/" + FileUpload1.PostedFile.FileName;
                    FileUpload1.SaveAs(MapPath(q));

                    int max_id = m.get_maxid("PhotoGallery");
                    //Inserting in db
                    string q1 = string.Format("insert into PhotoGallery values ({0},'{1}','{2}','{3}') ", max_id, q, cat, User);

                    SqlCommand insertCommand = new SqlCommand(q1, m.cn);
                    insertCommand.ExecuteNonQuery();
                    Response.Write("Image Uploaded");

            }

            m.cn.Close();
            m = null;
        }
    }