protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (Flpimages.HasFile == true)
         {
             long   FacultyID = id.auto1("FacultyTbl", "ID");
             string dateNow   = DateTime.Now.ToString("yyyy-MM-dd hh:mm tt");
             Flpimages.SaveAs(Server.MapPath("~/FacultyIMG/" + FacultyID + Flpimages.FileName));
             string path = "FacultyIMG/" + FacultyID + Flpimages.FileName;
             csedept.ExecuteQuery("Insert into FacultyTbl values (" + FacultyID + ",'" + txtFacultyName.Text + "','" + txtEmailID.Text + "','" + txtContactNo.Text + "','" + txtPassword.Text + "','" + path + "','" + dateNow + "',NULL,'1')");
             csedept.ClearInputs(Page.Controls);
             msgsuccess.Visible   = true;
             msgsuccess.InnerText = "Faculty Added successfully";
         }
         else
         {
             msgFails.Visible   = true;
             msgFails.InnerText = "Please Select Image";
         }
     }
     catch (Exception ex)
     {
         msgFails.Visible   = true;
         msgFails.InnerText = ex.Message;
         EntryForm.Visible  = true;
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (Flpimages.HasFile == true)
            {
                long   ID      = id.auto1("StudentTbl", "ID");
                string dateNow = DateTime.Now.ToString("yyyy-MM-dd hh:mm tt");
                Flpimages.SaveAs(Server.MapPath("~/StudentIMG/" + ID + Flpimages.FileName));
                string path = "StudentIMG/" + ID + Flpimages.FileName;

                csedept.ExecuteQuery("Insert into StudentTbl values (" + ID + ",'" + ddldept.SelectedValue + "','" + txtrollno.Text + "','" + txtName.Text + "','" + txtfathername.Text + "','" + txtmothername.Text + "','" + txtEmailID.Text + "','" + txtContactNo.Text + "','" + txtfcontactno.Text + "','" + txtmcontactno.Text + "','" + txtparentspassword.Text + "','" + txtPassword.Text + "','" + txtaddr.Text + "','" + ddlyear.SelectedValue + "','" + ddlsemester.SelectedValue + "','" + path + "','" + dateNow + "',NULL,'1')");
                csedept.ClearInputs(Page.Controls);
                getAllStudents();
                msgsuccess.Visible   = true;
                msgsuccess.InnerText = "Student Added successfully";
            }
            else
            {
                msgFails.Visible   = true;
                msgFails.InnerText = "Please Select Image";
            }
        }
        catch (Exception ex)
        {
            msgFails.Visible   = true;
            msgFails.InnerText = ex.Message;
            EntryForm.Visible  = true;
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            string dateNow = DateTime.Now.ToString("yyyy-MM-dd hh:mm tt");
            string FID     = Session["FID"].ToString();
            if (Flpimages.HasFile == true)
            {
                Flpimages.SaveAs(Server.MapPath("~/FacultyIMG/" + FID + Flpimages.FileName));
                string path = "FacultyIMG/" + FID + Flpimages.FileName;

                csedept.ExecuteQuery("Update FacultyTbl set Name='" + txtFacultyName.Text + "',EmailID='" + txtEmailID.Text + "', ContactNo='" + txtContactNo.Text + "', Password='******',Image='" + path + "', ModifiedDate='" + dateNow + "' where ID='" + FID + "' ");
                csedept.ClearInputs(Page.Controls);
                getAllFaculty();
                msgsuccess.Visible   = true;
                msgsuccess.InnerText = "Faculty Updated successfully";
            }
            else
            {
                csedept.ExecuteQuery("Update FacultyTbl set Name='" + txtFacultyName.Text + "',EmailID='" + txtEmailID.Text + "', ContactNo='" + txtContactNo.Text + "', Password='******', ModifiedDate='" + dateNow + "' where ID='" + FID + "' ");
                csedept.ClearInputs(Page.Controls);
                getAllFaculty();
                msgsuccess.Visible   = true;
                msgsuccess.InnerText = "Faculty Updated successfully";
            }
            btnSave.Visible   = true;
            btnUpdate.Visible = false;
        }
        catch (Exception ex)
        {
            msgFails.Visible   = true;
            msgFails.InnerText = ex.Message;
            btnUpdate.Visible  = true;
            EntryForm.Visible  = true;
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            string dateNow   = DateTime.Now.ToString("yyyy-MM-dd hh:mm tt");
            string StudentID = Session["StudentID"].ToString();
            if (Flpimages.HasFile == true)
            {
                Flpimages.SaveAs(Server.MapPath("~/StudentIMG/" + StudentID + Flpimages.FileName));
                string path = "StudentIMG/" + StudentID + Flpimages.FileName;

                csedept.ExecuteQuery("Update StudentTbl set DeptID='" + ddldept.SelectedValue + "' , RollNo = '" + txtrollno.Text + "', Name='" + txtName.Text + "', FathersName = '" + txtfathername.Text + "', MothersName = '" + txtmothername.Text + "',EmailID='" + txtEmailID.Text + "', ContactNo='" + txtContactNo.Text + "', FathersContactNo = '" + txtfcontactno.Text + "', MothersContactNo = '" + txtmcontactno.Text + "', ParentsLoginPassword = '******', Password='******',Address = '" + txtaddr.Text + "', Year='" + ddlyear.SelectedValue + "',Semester = '" + ddlsemester.SelectedValue + "',Image='" + path + "', ModifiedDate='" + dateNow + "' where ID='" + StudentID + "'");
                csedept.ClearInputs(Page.Controls);
                getAllStudents();
                msgsuccess.Visible   = true;
                msgsuccess.InnerText = "Student Updated successfully";
            }
            else
            {
                csedept.ExecuteQuery("Update StudentTbl set DeptID='" + ddldept.SelectedValue + "' , RollNo = '" + txtrollno.Text + "', Name='" + txtName.Text + "', FathersName = '" + txtfathername.Text + "', MothersName = '" + txtmothername.Text + "',EmailID='" + txtEmailID.Text + "', ContactNo='" + txtContactNo.Text + "', FathersContactNo = '" + txtfcontactno.Text + "', MothersContactNo = '" + txtmcontactno.Text + "', ParentsLoginPassword = '******', Password='******',Address = '" + txtaddr.Text + "', Year='" + ddlyear.SelectedValue + "',Semester = '" + ddlsemester.SelectedValue + "', ModifiedDate='" + dateNow + "' where ID='" + StudentID + "'");
                csedept.ClearInputs(Page.Controls);
                getAllStudents();
                msgsuccess.Visible   = true;
                msgsuccess.InnerText = "Student Updated successfully";
            }
            btnSave.Visible   = true;
            btnUpdate.Visible = false;
        }
        catch (Exception ex)
        {
            msgFails.Visible   = true;
            msgFails.InnerText = ex.Message;
            btnUpdate.Visible  = true;
            EntryForm.Visible  = true;
        }
    }