//
        //Function call to getPictureID(), gets Question_ID, adds question and picture
        //
        public String addPictureQuestion(Questions q, Picture p)
        {
            p.picture_ID = this.getPictureID();
            q.question_ID = this.getNext();
            try
            {
                conn.Open();
                cmd = new SqlCommand("Insert into Questions(Question_ID, Exam_Type, Format, Question, Option1, Option2, Option3, Option4, Solution, Marks, Section,Picture_ID) values('" + q.question_ID + "','" + q.exam_Type + "','" + q.format + "','" + q.question + "','" + q.option1 + "','" + q.option2 + "','" + q.option3 + "','" + q.option4 + "','" + q.solution + "'," + q.marks + ",'" + q.section + "','" + p.picture_ID + "')", conn);
                int result1 = cmd.ExecuteNonQuery();

                cmd = new SqlCommand();
                cmd.CommandText = "Insert into Pictures(Picture_ID,Picture)" + " values(@Picture_ID, @Picture)";
                cmd.Parameters.Add("@Picture_ID", System.Data.SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@Picture", System.Data.SqlDbType.Image);
                cmd.Parameters["@Picture_ID"].Value = p.picture_ID;
                cmd.Parameters["@Picture"].Value = p.image;
                cmd.Connection = conn;
                int result = cmd.ExecuteNonQuery();
                conn.Close();
                if (result == 1 && result1 == 1)
                    return "Question was successfully added & assigned Question ID " + q.question_ID + ".";
                else
                    return "Sorry. There was some error.";

            }
            catch (Exception ex)
            {
                conn.Close();
                return ex.Message;
            }
        }
 //
 //Function call to getPictureID(), Updates fields of Question, returns Success or Error Message
 //
 public string updatePictureQuestion(Questions q, Picture p)
 {
     try
     {
         p.picture_ID = this.getPictureID();
         conn.Open();
         cmd = new SqlCommand("Update Questions SET Question_ID='" + q.question_ID + "', Exam_Type='" + q.exam_Type + "', Format ='" + q.format + "', Question = '" + q.question + "', Option1 = '" + q.option1 + "', Option2 = '" + q.option2 + "', Option3 = '" + q.option3 + "', Option4 = '" + q.option4 + "', Solution = '" + q.solution + "', Marks = " + q.marks + ", Section = '" + q.section + "', Picture_ID = '"+ p.picture_ID +"' Where Question_ID='" + q.question_ID + "'", conn);
         int i = cmd.ExecuteNonQuery();
         cmd = new SqlCommand();
         cmd.CommandText = "Insert into Pictures(Picture_ID,Picture)" + " values(@Picture_ID, @Picture)";
         cmd.Parameters.Add("@Picture_ID", System.Data.SqlDbType.VarChar, 50);
         cmd.Parameters.Add("@Picture", System.Data.SqlDbType.Image);
         cmd.Parameters["@Picture_ID"].Value = p.picture_ID;
         cmd.Parameters["@Picture"].Value = p.image;
         cmd.Connection = conn;
         int j = cmd.ExecuteNonQuery();
         conn.Close();
         if (i == 1 && j==1)
             return "Question was successfully updated.";
         else
             return"Some error occured. Sorry for the inconvenience.";
     }
     catch (Exception ex)
     {
         conn.Close();
         return "Some error occured. Sorry for the inconvenience.";
     }
 }
 //
 //Validates fields before updating Picture Question
 //
 public String updatePictureQuestion(Questions e, Picture p)
 {
     string feedback = "";
     bool feed = false;
     int i = 0;
     if (e.exam_Type == "")
     {
         feedback += (++i) + ". Exam Type  ";
         feed = true;
     }
     if (e.question == "")
     {
         feedback += (++i) + ". Question  ";
         feed = true;
     }
     if (e.solution == "")
     {
         feedback += (++i) + ". Solution  ";
         feed = true;
     }
     if (e.marks <= 0)
     {
         feedback += (++i) + ". Marks  ";
         feed = true;
     }
     if (e.section == "")
     {
         feedback += (++i) + ". Section  ";
         feed = true;
     }
     if (e.option1 == "")
     {
         feedback += (++i) + ". Option1  ";
         feed = true;
     }
     if (e.option2 == "")
     {
         feedback += (++i) + ". Option2  ";
         feed = true;
     }
     if (e.option3 == "")
     {
         feedback += (++i) + ". Option3  ";
         feed = true;
     }
     if (e.option4 == "")
     {
         feedback += (++i) + ". Option4  ";
         feed = true;
     }
     if (p.image == null)
     {
         feedback += (++i) + ". Image ";
         feed = true;
     }
     if (feed)
     {
         //Not valid: Returns erroneous fields
         return ("Please enter valid entries for: " + feedback);
     }
     else
     {
         //Valid: Updates Question and returns Success or Error Message
         string feedDAL = cs.updatePictureQuestion(e, p);
         return feedDAL;
     }
 }