protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (ddlDivision.SelectedValue != "-Select-")
         {
             int            code   = Converter.GetInteger(ddlDivision.SelectedValue);
             A2ZDIVISIONDTO getDTO = (A2ZDIVISIONDTO.GetInformation(code));
             if (getDTO.DivisionCode > 0)
             {
                 //txtcode.Text = Converter.GetString(getDTO.DivisionCode);
                 //txtDistcode.Focus();
                 //clearInfo();
             }
             ddlDistrict.SelectedIndex = 0;
             ddlUpzila.SelectedIndex   = 0;
             ddlThana.SelectedIndex    = 0;
             DistrictDropdown();
             UpzilaDropdown();
             ThanaDropdown();
         }
     }
     catch (Exception ex)
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('System Error.ddlDivision_SelectedIndexChanged Problem');</script>");
         //throw ex;
     }
 }
        protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e)
        {
            DistrictDropdown();

            try
            {
                if (ddlDivision.SelectedValue != "-Select-")
                {
                    int            code   = Converter.GetInteger(ddlDivision.SelectedValue);
                    A2ZDIVISIONDTO getDTO = (A2ZDIVISIONDTO.GetInformation(code));
                    if (getDTO.DivisionCode > 0)
                    {
                        txtDivicode.Text          = Converter.GetString(getDTO.DivisionCode);
                        hdnDiviCode.Text          = Converter.GetString(getDTO.DivisionCode);
                        hdnDiviOrgCode.Text       = Converter.GetString(getDTO.DivisionOrgCode);
                        ddlDistrict.SelectedIndex = 0;
                        txtDistDescription.Focus();
                        clearInfo();
                    }
                    else
                    {
                        //        ddlDivision.SelectedValue = "-Select-";
                        ddlDistrict.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlDivision.SelectedValue == "-Select-")
            {
                clearInfo();
                ddlDistrict.SelectedIndex = 0;
                return;
            }


            DistrictDropdown();

            try
            {
                if (ddlDivision.SelectedValue != "-Select-")
                {
                    int            code   = Converter.GetInteger(ddlDivision.SelectedValue);
                    A2ZDIVISIONDTO getDTO = (A2ZDIVISIONDTO.GetInformation(code));
                    if (getDTO.DivisionCode > 0)
                    {
                    }
                    else
                    {
                        ddlDistrict.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void ddlDivision_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlDivision.SelectedValue == "-Select-")
            {
                clearInfo();
                ddlDivision.Focus();
            }

            try
            {
                if (ddlDivision.SelectedValue != "-Select-")
                {
                    int            code   = Converter.GetInteger(ddlDivision.SelectedValue);
                    A2ZDIVISIONDTO getDTO = (A2ZDIVISIONDTO.GetInformation(code));
                    if (getDTO.DivisionCode > 0)
                    {
                        hdnDiviCode.Text    = Converter.GetString(getDTO.DivisionCode);
                        hdnDiviOrgCode.Text = Converter.GetString(getDTO.DivisionOrgCode);
                        txtDescription.Text = Converter.GetString(getDTO.DivisionDescription);
                        txtDescription.Focus();
                        BtnSubmit.Visible = false;
                        BtnUpdate.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlDivision.SelectedValue == "-Select-" && txtDescription.Text != string.Empty)
                {
                    gvDetail();
                    gvDetailInfo.Visible = false;

                    int totrec = gvDetailInfo.Rows.Count;

                    int lastDiviCode = (totrec + 1);
                    hdnDiviCode.Text = Converter.GetString(lastDiviCode);
                    string result = hdnDiviCode.Text + "000000";
                    hdnDiviOrgCode.Text = Converter.GetString(result);

                    if (lastDiviCode < 10)
                    {
                        hdnDiviCode.Text = Converter.GetString("0" + lastDiviCode);
                    }

                    A2ZDIVISIONDTO objDTO = new A2ZDIVISIONDTO();

                    objDTO.DivisionCode        = Converter.GetInteger(hdnDiviCode.Text);
                    objDTO.DivisionOrgCode     = Converter.GetInteger(hdnDiviOrgCode.Text);
                    objDTO.DivisionDescription = Converter.GetString(txtDescription.Text);

                    int roweffect = A2ZDIVISIONDTO.InsertInformation(objDTO);
                    if (roweffect > 0)
                    {
                        DivisionDropdown();
                        clearInfo();
                        BtnUpdate.Visible = false;
                        BtnSubmit.Visible = true;
                        gvDetail();
                        gvDetailInfo.Visible = false;
                        txtDescription.Text  = string.Empty;
                        txtDescription.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void txtcode_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (txtDivicode.Text != string.Empty)
                {
                    int            code   = Converter.GetInteger(txtDivicode.Text);
                    A2ZDIVISIONDTO getDTO = (A2ZDIVISIONDTO.GetInformation(code));
                    if (getDTO.DivisionCode > 0)
                    {
                        ddlDivision.SelectedValue = Converter.GetString(getDTO.DivisionCode);
                        hdnDiviCode.Text          = Converter.GetString(getDTO.DivisionCode);
                        hdnDiviOrgCode.Text       = Converter.GetString(getDTO.DivisionOrgCode);
                        clearInfo();
                        DistrictDropdown();
                        ddlDistrict.SelectedValue = "-Select-";
                        txtDistDescription.Focus();
                    }
                    else
                    {
                        //String csname1 = "PopupScript";
                        //Type cstype = GetType();
                        //ClientScriptManager cs = Page.ClientScript;

                        //if (!cs.IsStartupScriptRegistered(cstype, csname1))
                        //{
                        //    String cstext1 = "alert('Invalid Division Code');";
                        //    cs.RegisterStartupScript(cstype, csname1, cstext1, true);

                        //}
                        txtDivicode.Text = string.Empty;
                        txtDivicode.Focus();
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Invalid Division Code');", true);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 protected void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (ddlDivision.SelectedValue != "-Select-")
     {
         A2ZDIVISIONDTO UpDTO = new A2ZDIVISIONDTO();
         UpDTO.DivisionCode        = Converter.GetInteger(hdnDiviCode.Text);
         UpDTO.DivisionOrgCode     = Converter.GetInteger(hdnDiviOrgCode.Text);
         UpDTO.DivisionDescription = Converter.GetString(txtDescription.Text);
         int roweffect = A2ZDIVISIONDTO.UpdateInformation(UpDTO);
         if (roweffect > 0)
         {
             DivisionDropdown();
             clearInfo();
             BtnUpdate.Visible = false;
             BtnSubmit.Visible = true;
             gvDetail();
             gvDetailInfo.Visible = false;
             txtDescription.Text  = string.Empty;
             txtDescription.Focus();
         }
     }
 }