protected void btnSignIn_Click(object sender, EventArgs e)
    {
        try
        {
            objBal = new ClsBAL();
            string message = "";

                message = objBal.AddAgent(txtName.Text.Trim(),
                    "",Convert.ToDateTime("1/1/1989"),
                    txtCity.Text.Trim().ToString(),
                    ddlState.SelectedItem.Text.ToString(),
                    txtAddress.Text.Trim().ToString(),
                    txtPinCode.Text.Trim().ToString(),
                    txtMobileNo.Text.Trim().ToString(),
                     "", "", txtEmailId.Text.Trim().ToString(), "", "", "Approved",
                    txtUsername.Text.Trim().ToString(),
                    txtPassword.Text.Trim().ToString(),
                    0,
                   0, Convert.ToInt32("0"),"User",ddlcountry.SelectedValue,"","","","","","");

                lblMsg.Text = message;

                lblMsg.Visible = true;

                if (message == "Agent registration is completed successfully.")
                {
                    lblMsg.ForeColor = System.Drawing.Color.Green;
                    mail();
                    lblMsg.Text = "User registration is completed successfully";
                }
                lblMsg.ForeColor = System.Drawing.Color.Red;

        }
        catch (Exception ex)
        {

        }
    }
    protected void btnSaveUD_Click(object sender, EventArgs e)
    {
        try
        {
            tdmsg.Visible = false;
            lblMainMsg.Text = "";
            tdmsg.Visible = false;
            lblMainMsg.Text = "";
            string message = "";

            objBAL = new ClsBAL();
         message =   objBAL.AddAgent(txtName.Text.Trim(), "", Convert.ToDateTime("1/1/1900"), txtCity.Text.Trim().ToString(),
         ddlState.SelectedItem.Text.ToString(),
         txtAddress.Text.Trim().ToString(),
         txtPinCode.Text.Trim().ToString(),
         txtMobileNo.Text.Trim().ToString(),
          "", "", txtEmailId.Text.Trim().ToString(), "", "", "1",
         txtUsername.Text.Trim().ToString(),
         txtPassword.Text.Trim().ToString(),
         0,
        0, Convert.ToInt32("0"), "CSE", ddlcountry.SelectedValue,"","","","","","");

            // lblMainMsg.Text = message;

         if (message == "Agent registration is completed successfully.")
         {
             Label1.Text = "CSE Registration is Completed Successfully";

             mail();
             BindUsers();
             Cleardata();

             MVUsers.ActiveViewIndex = 0;
             MVUsers.Visible = true;
             lblMainMsg.ForeColor = System.Drawing.Color.Green;

         }
         else
         {
             lblMainMsg.ForeColor = System.Drawing.Color.Red;
             tdmsg.Visible = true;
             lblMainMsg.Text = message;
         }

        }
        catch (Exception ex)
        {
            objBAL.Logerror(this.Page.ToString(), "btnSaveUD_Click", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now);
            throw ex;
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {

            objBal = new ClsBAL();

            string message = "";
            if (btnRegister.Text == "Register")
            {
                if (txtDateOfBirth.Text == "")
                {
                    txtDateOfBirth.Text = "1/1/1990";
                }
                if (txtCommissionPercentage.Text == "")
                {
                    txtCommissionPercentage.Text = "0";
                }
                if (chkDomesticFlights.Checked == false)
                {
                    lblDomesticFlights.Text = "0";

                }
                else
                {
                    lblDomesticFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkBuses.Checked == false)
                {
                    lblBuses.Text = "0";
                }
                else
                {
                    lblBuses.Text = "1";

                }
                if (chkHotels.Checked == false)
                {
                    lblHotels.Text = "0";
                }
                else
                {
                    lblHotels.Text = "1";
                }
                if (chkRecharge.Checked == false)
                {
                    lblRecharge.Text = "0";
                }
                else
                {
                    lblRecharge.Text = "1";

                }

                message = objBal.AddAgent(txtAgentName.Text.Trim().ToString(),
                    ddlType.SelectedItem.Text.ToString(),
                    Convert.ToDateTime(txtDateOfBirth.Text.ToString()),
                    txtCity.Text.Trim().ToString(),
                    ddlState.SelectedItem.Text.ToString(),
                    txtAddress.Text.Trim().ToString(),
                    txtPinCode.Text.Trim().ToString(),
                    txtMobileNo.Text.Trim().ToString(),
                    txtAlternateMobileNo.Text.Trim().ToString(),
                    txtLandlineNo.Text.Trim().ToString(),
                    txtEmailId.Text.Trim().ToString(),
                    txtPAN.Text.Trim().ToString(),
                    txtDetails.Text.Trim().ToString(),
                    ddlStatus.SelectedItem.Text.ToString(),

                    txtUsername.Text.Trim().ToString(),
                    txtPassword.Text.Trim().ToString(),
                    Convert.ToInt32(Session["UserID"].ToString()),
                    Convert.ToInt32(Session["UserID"].ToString()), Convert.ToInt32(txtCommissionPercentage.Text.ToString()), ddlBSD.SelectedItem.Text, "",
                    lblDomesticFlights.Text.ToString(),
                    lblInterNationalFlights.Text.ToString(),
                    lblBuses.Text.ToString(),
                    lblHotels.Text.ToString(),
                    lblRecharge.Text.ToString(),
                      txtDistrict.Text.Trim().ToString()

                    );
                if (message == "Agent registration is completed successfully.")
                {
                    lblMsg.Text = "Employee Registration is compleated successfully";
                }

            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {

            objBal = new ClsBAL();

            string message = "";
            if (btnRegister.Text == "Register")
            {
                if (txtDateOfBirth.Text == "")
                {
                    txtDateOfBirth.Text = "1/1/1990";
                }
                if (txtCommissionPercentage.Text == "")
                {
                    txtCommissionPercentage.Text = "0";
                }
                if (chkDomesticFlights.Checked == false)
                {
                    lblDomesticFlights.Text = "0";

                }
                else
                {
                    lblDomesticFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkBuses.Checked == false)
                {
                    lblBuses.Text = "0";
                }
                else
                {
                    lblBuses.Text = "1";

                }
                if (chkHotels.Checked == false)
                {
                    lblHotels.Text = "0";
                }
                else
                {
                    lblHotels.Text = "1";
                }
                if (chkRecharge.Checked == false)
                {
                    lblRecharge.Text = "0";
                }
                else
                {
                    lblRecharge.Text = "1";

                }
                if (Session["UserID"] != null)
                {

                    if (Session["Role"].ToString() == "Distributor")
                    {
                        ddlRole.SelectedItem.Text = "Agent";
                        role = "Agent";

                    }
                    else  if (Session["Role"].ToString() == "Admin")
                    {

                        role = ddlRole.SelectedItem.Text;

                    }
                    else if (Session["Role"].ToString() == "BSD")
                    {

                        role = ddlBSD.SelectedItem.Text;

                    }
                }

                message = objBal.AddAgent(txtAgentName.Text.Trim().ToString(),
                    ddlType.SelectedItem.Text.ToString(),
                    Convert.ToDateTime(txtDateOfBirth.Text.ToString()),
                    txtCity.Text.Trim().ToString(),
                    ddlState.SelectedItem.Text.ToString(),
                    txtAddress.Text.Trim().ToString(),
                    txtPinCode.Text.Trim().ToString(),
                    txtMobileNo.Text.Trim().ToString(),
                    txtAlternateMobileNo.Text.Trim().ToString(),
                    txtLandlineNo.Text.Trim().ToString(),
                    txtEmailId.Text.Trim().ToString(),
                    txtPAN.Text.Trim().ToString(),
                    txtDetails.Text.Trim().ToString(),
                    ddlStatus.SelectedItem.Text.ToString(),

                    txtUsername.Text.Trim().ToString(),
                    txtPassword.Text.Trim().ToString(),
                    Convert.ToInt32(Session["UserID"].ToString()),
                    Convert.ToInt32(Session["UserID"].ToString()), Convert.ToInt32(txtCommissionPercentage.Text.ToString()), role, "",
                    lblDomesticFlights.Text.ToString(),
                    lblInterNationalFlights.Text.ToString(),
                    lblBuses.Text.ToString(),
                    lblHotels.Text.ToString(),
                    lblRecharge.Text.ToString(),
                      txtDistrict.Text.Trim().ToString()

                    );

                if (message == "Username is already existed. Please choose another one.")
                {
                    lblMsg.InnerHtml = "UserName/EmailId is already exists please choose another one";
                }

                if (message == "Agent registration is completed successfully.")
                {
                    mail();

                    lblDomesticFlights.Visible = false;
                    lblInterNationalFlights.Visible = false;
                    lblBuses.Visible = false;
                    lblHotels.Visible = false;
                    lblRecharge.Visible = false;
                    //lblMsg.InnerHtml = message;
                    if (Session["Role"].ToString() == "Admin" || Session["Role"].ToString() == "Distributor")
                    {
                        if (ddlRole.SelectedItem.Text == "Agent")
                        {
                            lblMsg.InnerHtml = message;
                        }
                        else if (ddlRole.SelectedItem.Text == "Distributor")
                        {
                            lblMsg.InnerHtml = "Distributor Registration  is completed successfully.";
                        }
                        else if (ddlRole.SelectedItem.Text == "BSD")
                        {
                            lblMsg.InnerHtml = "BSD Registration  is completed successfully.";
                        }
                    }
                    else
                    {
                        if (ddlBSD.SelectedItem.Text == "Agent")
                        {
                            lblMsg.InnerHtml = message;
                        }
                        else
                        {
                            lblMsg.InnerHtml = "Employee Registration is compleated successfully.";
                        }
                    }

                }

            }
            else if (btnRegister.Text == "Update")
            {
                if (txtDateOfBirth.Text == "")
                {
                    txtDateOfBirth.Text = "1/1/1990";
                }

                if (chkDomesticFlights.Checked == false)
                {
                    lblDomesticFlights.Text = "0";

                }
                else
                {
                    lblDomesticFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkInternationalFlights.Checked == false)
                {
                    lblInterNationalFlights.Text = "0";
                }
                else
                {
                    lblInterNationalFlights.Text = "1";
                }
                if (chkBuses.Checked == false)
                {
                    lblBuses.Text = "0";
                }
                else
                {
                    lblBuses.Text = "1";

                }
                if (chkHotels.Checked == false)
                {
                    lblHotels.Text = "0";
                }
                else
                {
                    lblHotels.Text = "1";
                }
                if (chkRecharge.Checked == false)
                {
                    lblRecharge.Text = "0";
                }
                else
                {
                    lblRecharge.Text = "1";
                }

                message = objBal.UpdateAgent(txtAgentName.Text.Trim().ToString(),
                    ddlType.SelectedItem.Text.ToString(),
                    Convert.ToDateTime(txtDateOfBirth.Text),
                    txtCity.Text.Trim().ToString(),
                    ddlState.SelectedItem.Text.ToString(),
                    txtAddress.Text.Trim().ToString(),
                    txtPinCode.Text.Trim().ToString(),
                    txtMobileNo.Text.Trim().ToString(),
                    txtAlternateMobileNo.Text.Trim().ToString(),
                    txtLandlineNo.Text.Trim().ToString(),
                    txtEmailId.Text.Trim().ToString(),
                    txtPAN.Text.Trim().ToString(),
                    txtDetails.Text.Trim().ToString(),
                    ddlStatus.SelectedItem.Text.ToString(),
                    txtPassword.Text.Trim().ToString(),
                    Convert.ToInt32(btnRegister.CommandArgument.ToString()),
                    Convert.ToInt32(Session["UserID"].ToString()), Convert.ToInt32(txtCommissionPercentage.Text.ToString()),
                    lblDomesticFlights.Text.ToString(),
                    lblInterNationalFlights.Text.ToString(),
                    lblBuses.Text.ToString(),
                    lblHotels.Text.ToString(),
                    lblRecharge.Text.ToString()

                    );
            }
             //lblMsg.InnerHtml = message;
            lblDomesticFlights.Visible = false;
            lblInterNationalFlights.Visible = false;
            lblBuses.Visible = false;
            lblHotels.Visible = false;
            lblRecharge.Visible = false;

        }
        catch (Exception ex)
        {
            lblMsg.InnerHtml = ex.Message;
        }
    }