protected void txtAmount_TextChanged(object sender, EventArgs e)
    {
        try
        {
            TextBox txt = (TextBox)sender;
            DataControlFieldCell gridcell = (DataControlFieldCell)txt.Parent;
            GridViewRow          row      = (GridViewRow)gridcell.Parent;
            TextBox txtAmount             = (TextBox)row.FindControl("txtAmount");
            if (txtAmount.Text == "")
            {
                txtAmount.Text = "0";
            }

            txtAmount.Text = Utils.CleanHTML(txtAmount.Text);
            txtAmount.Text = txtAmount.Text.Replace("$", " ").Trim();
            txtAmount.Text = txtAmount.Text.Replace("%", " ").Trim();
            try
            {
                double i = 0.0;
                if (txtAmount.Text != "")
                {
                    i = double.Parse(txtAmount.Text);
                }
                else if (txtAmount.Text.Trim() == "")
                {
                    lblerror.Text = "Please enter numeric/decimal only";
                    return;
                }
            }
            catch (Exception ex)
            {
                lblerror.CssClass = "error";
                lblerror.Text     = "Please enter numeric/decimal only";

                return;
            }
            if (ddlcountry.SelectedIndex == 0)
            {
                lblerror.Text = "Please select the role first";
            }

            else
            {
                //TextBox txtPercentage = (TextBox)row.FindControl("txtpercentage");
                RadioButtonList rbList = (RadioButtonList)row.FindControl("rbType");

                int        feeTypeId      = Conversion.ParseInt(gvCommissionType.DataKeys[row.RowIndex]["LookupTypeID"]);
                int        countryId      = Int32.Parse(ddlcountry.SelectedValue);
                int        organizationId = Int32.Parse(ddlstewardshiptype.SelectedValue);
                Commission com            = new Commission();

                com.CommissionId = 0;
                com.Amount       = Conversion.ParseDecimal(txtAmount.Text.Replace('$', ' ').Trim());
                com.Percentage   = Conversion.ParseDecimal(txtAmount.Text.Replace('%', ' ').Trim());
                // com.Percentage = clsCommon.ParseDecimal(txtPercentage.Text);
                com.TypeId    = feeTypeId;
                com.CountryId = countryId;

                com.OrganizationId    = organizationId;
                com.CreatedById       = LoginMemberId;
                com.TntCommissionType = Conversion.ParseInt(rbList.SelectedValue);

                com.IsActive = true;

                if (rbList.SelectedValue == "1")
                {
                    com.Percentage = 0;
                }
                else if (rbList.SelectedValue == "2")
                {
                    com.Amount = 0;
                    if (Conversion.ParseDouble(txtAmount.Text.Trim()) >= 9)
                    {
                        Response.Write("<script> alert('hi'); </script>");
                        //   ScriptManager.RegisterStartupScript(upnlsearch, upnlsearch.GetType(), "confirm", "return confirm('Changing the language will clear the text in the textboxes. Click OK to proceed.');", true);

                        //ScriptManager.RegisterClientScriptBlock
                    }
                }
                else
                {
                    com.Amount     = 0;
                    com.Percentage = 0;
                }

                if (Commission.CommissionSetting(com))
                {
                    lblerror.Text = "Commission updated successfully.";
                    LoadCommissionInfo(Int32.Parse(ddlcountry.SelectedValue), Int32.Parse(ddlstewardshiptype.SelectedValue), 2);
                }
            }
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "commission.txtAmount_TextChanged", ex);
        }
    }
    private void saveCommission(GridViewRow gr)
    {
        try
        {
            //TextBox txt = (TextBox)sender;
            //DataControlFieldCell gridcell = (DataControlFieldCell)txt.Parent;
            GridViewRow row       = gr;
            TextBox     txtAmount = (TextBox)row.FindControl("txtAmount");
            if (txtAmount.Text == "")
            {
                txtAmount.Text = "0";
            }

            txtAmount.Text = Utils.CleanHTML(txtAmount.Text);
            txtAmount.Text = txtAmount.Text.Replace("$", " ").Trim();
            txtAmount.Text = txtAmount.Text.Replace("%", " ").Trim();
            try
            {
                double i = 0.0;
                if (txtAmount.Text != "")
                {
                    i = double.Parse(txtAmount.Text);
                }
                else if (txtAmount.Text.Trim() == "")
                {
                    lblerror.Text = "Please enter numeric/decimal only";
                    Flag          = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                lblerror.CssClass = "custom-absolute-alert alert-danger";
                lblerror.Text     = "Please enter numeric/decimal only";
                ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                Flag = false;
                return;
            }
            if (ddlcountry.SelectedIndex == 0)
            {
                Flag          = false;
                lblerror.Text = "Please select the country first";
                ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
            }

            else
            {
                //TextBox txtPercentage = (TextBox)row.FindControl("txtpercentage");
                RadioButtonList rbList = (RadioButtonList)row.FindControl("rbType");

                int        OrganizationSubTypeId = Conversion.ParseInt(gvCommissionType.DataKeys[row.RowIndex]["OrganizationSubTypeId"]);
                int        countryId             = Int32.Parse(ddlcountry.SelectedValue);
                int        StewardshipID         = Int32.Parse(ddlstewardshiptype.SelectedValue);
                Commission com = new Commission();

                com.CommissionId = 0;
                com.Amount       = Conversion.ParseDecimal(txtAmount.Text.Replace('$', ' ').Trim());
                com.Percentage   = Conversion.ParseDecimal(txtAmount.Text.Replace('%', ' ').Trim());
                // com.Percentage = Conversion.ParseDecimal(txtPercentage.Text);
                com.OrganizationSubTypeId = OrganizationSubTypeId;
                com.CountryId             = countryId;

                com.StewardshipID     = StewardshipID;
                com.CreatedById       = LoginMemberId;
                com.TntCommissionType = Conversion.ParseInt(rbList.SelectedValue);

                com.IsActive = true;

                if (rbList.SelectedValue == "1")
                {
                    com.Percentage = 0;
                }
                else if (rbList.SelectedValue == "2")
                {
                    com.Amount = 0;
                    if (Conversion.ParseDouble(txtAmount.Text.Trim()) > 100)
                    {
                        Response.Write("<script> alert('invalid percentage'); </script>");
                        ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                        Flag = false;
                        //   ScriptManager.RegisterStartupScript(upnlsearch, upnlsearch.GetType(), "confirm", "return confirm('Changing the language will clear the text in the textboxes. Click OK to proceed.');", true);

                        //ScriptManager.RegisterClientScriptBlock
                    }
                }
                else
                {
                    com.Amount     = 0;
                    com.Percentage = 0;
                }

                if (!Commission.CommissionSetting(com))
                {
                    lblerror.Text = "Please enter numeric/decimal only";
                    ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                    Flag = false;
                    //     LoadCommissionInfo(Int32.Parse(ddlcountry.SelectedValue), Int32.Parse(ddlstewardshiptype.SelectedValue), 2);
                }
            }
        }
        catch (Exception ex)
        {
            Flag = false;
            new SqlLog().InsertSqlLog(0, "commission.txtAmount_TextChanged", ex);
        }
    }