protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtFName.Text == "" || txtLName.Text == "" || txtAddress.Text == "" || txtEMail.Text == "" || !fuEmp.HasFile)
        {
            lblError.Text = "Please enter all values";
            lblError.Visible = true;
        }
        else if (txtAddress.Text != "" && txtEMail.Text != "" && txtFName.Text != "" && txtLName.Text != "" && fuEmp.HasFile) // validate controls
        {

            lblError.Visible = false;// initially no message

            DbConnect dc = new DbConnect();

            try
            {
                if (fuEmp.PostedFile.ContentType.ToString() == "image/jpeg") // check the image format
                {
                    fuEmp.SaveAs(Server.MapPath("EmpImage/" + fuEmp.PostedFile.FileName));// upload image to a folder
                    String url = "EmpImage/" + fuEmp.PostedFile.FileName;

                    String qry1 = "insert into login (username,password,status) values ('" + txtEMail.Text + "' , 'reseption' , 'reseption')";
                    String qry = "insert into Employee(fname,lname,address,email,Picture) values ('" + txtFName.Text + "' , '" + txtLName.Text + "' , '" + txtAddress.Text + "' , '" + txtEMail.Text + "' , '" + url + "');";
                    bool conf1 = dc.insertIt(qry1);
                    bool conf = dc.insertIt(qry);

                    if (conf == false || conf1 == false)
                        lblError.Text = "Cannot be added";
                    else
                        lblError.Text = "Successfully added";

                    fillGrid();//refresh the grid
                }
                else
                {
                    lblError.Text = "Please insert JPG images only";
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }

        lblError.Visible = true;//set visible the message
    }
    protected void btn_edit_days_Click(object sender, EventArgs e)
    {
        //dbCOnnect db = new dbCOnnect();
         DbConnect db = new DbConnect();

         string qry1 = "select Package_id from mainPackege where name='" + ddmain_day.Text + "'";
         DataTable dt = db.selectIt(qry1);
         string package_id = dt.Rows[0][0].ToString();

         string qry2 = "select subPack_ID from subPackege where subPacge_name='" + ddsub_day.Text + "'";
         DataTable dt2 = db.selectIt(qry2);
         string subpackage_id = dt2.Rows[0][0].ToString();

         if (CheckBox2.Checked)
         {
         FileUpload2.Visible = true;

         FileUpload2.SaveAs(Server.MapPath("tour_main/" + FileUpload2.PostedFile.FileName));
         String url = "tour_main/" + FileUpload2.PostedFile.FileName;

         String qry = "update days_  set days_image='" + url + "',accomodation='" + txtday_accomodation.Text + "',description='" + txtdescription_days.Text + "' where day_no='" + ddday_no.Text + "' and subPcgId='" + subpackage_id + "' and packge_ID='" + package_id + "'";
         bool conf = db.insertIt(qry);

         if (conf == true)
         {
             lblday_edit.Text = "Successfully edited";
             filldaysTours();
         }
         else
         {
             lblday_edit.Text = "Cannot be edited";
         }
         }
         else
         {
         String qry = "update days_  set accomodation='" + txtday_accomodation.Text + "',description='" + txtdescription_days.Text + "' where day_no='" + ddday_no.Text + "' and subPcgId='" + subpackage_id + "' and packge_ID='" + package_id + "'";
         bool conf = db.insertIt(qry);

         if (conf == true)
         {
             lblday_edit.Text = "Successfully edited";
             filldaysTours();
         }
         else
         {
             lblday_edit.Text = "Cannot be edited";
         }

         }
    }
    protected void btn_edit_sub_Click(object sender, EventArgs e)
    {
        //dbCOnnect db = new dbCOnnect();

         DbConnect db = new DbConnect();

         String qry1 = "select Package_id from mainPackege where name='" + ddmain_sub.Text + "'";
         DataTable dt = db.selectIt(qry1);
         string package_id=dt.Rows[0][0].ToString();

         String qry2 = "update subPackege  set noofdays='" + txtnoofdays.Text + "',price='" + txtprice.Text + "' where  subPacge_Name='" + ddsubtour.Text + "' and packge_ID='"+package_id+ "'";

         bool conf = db.insertIt(qry2);

         if (conf == true)
         {
         lblsub_edit.Text = "Successfully edited";
         }
         else
         {
         lblsub_edit.Text = "Cannot be edited";
         }
    }
    protected void btn_edit_main_Click(object sender, EventArgs e)
    {
        //dbCOnnect db = new dbCOnnect();
         DbConnect db = new DbConnect();

         if (CheckBox1.Checked)
         {
         FileUpload1.Visible = true;
         FileUpload1.SaveAs(Server.MapPath("tour_main/" + FileUpload1.PostedFile.FileName));
         String url = "tour_main/" + FileUpload1.PostedFile.FileName;
         String qry = "update mainPackege set description='" + txtdescription_main.Text + "',image_main='" + url + "' where name='" + ddmaintours_main.Text + "'";
         bool conf = db.insertIt(qry);

         if (conf == true)
         {
             lblmain_edit.Text = "Successfully edited";
             fillMainTours();
         }

         else
         {
             lblmain_edit.Text = "Cannot be edited";
         }
         }
         else
         {
         String qry = "update  mainPackege set description='" + txtdescription_main.Text + "' where name='" + ddmaintours_main.Text + "'";
         bool conf = db.insertIt(qry);

         if (conf == true)
         {
             lblmain_edit.Text = "Successfully edited";
             fillMainTours();
         }

         else
         {
             lblmain_edit.Text = "Cannot be edited";
         }

         }
    }