protected void addListButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        regObj.FundCode      = fundCodeTextBox.Text;
        regObj.BranchCode    = branchCodeTextBox.Text;
        dvContent.Visible    = true;
        dinoGridView.Visible = true;
        int       unitQty        = 0;
        int       certNo         = 0;
        DataTable dtDinomination = opendMFDAO.getTableDinomination();
        DataRow   drDinomination = dtDinomination.NewRow();
        int       certQty        = 0;


        if (kTextBox.Text != "")
        {
            if (string.Compare(fundCodeTextBox.Text.Trim().ToString(), "BDF") == 0)
            {
                certNo  = opendMFDAO.GetMaxCertNo("K", regObj, userObj);
                certQty = Convert.ToInt32(kTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "K";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "10000";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 10000);
            }
        }
        if (jTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("J", regObj, userObj);
            certQty = Convert.ToInt32(jTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "J";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "5000";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 5000);
        }
        if (iTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("I", regObj, userObj);
            certQty = Convert.ToInt32(iTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "I";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "1000";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 1000);
        }
        if (hTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("H", regObj, userObj);
            certQty = Convert.ToInt32(hTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "H";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "500";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 500);
        }
        if (gTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("G", regObj, userObj);
            certQty = Convert.ToInt32(gTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "G";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "250";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 250);
        }
        if (fTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("F", regObj, userObj);
            certQty = Convert.ToInt32(fTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "F";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "100";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 100);
        }
        if (eTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("E", regObj, userObj);
            certQty = Convert.ToInt32(eTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "E";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "50";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 50);
        }
        if (dTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("D", regObj, userObj);
            certQty = Convert.ToInt32(dTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "D";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "20";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 20);
        }
        if (cTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("C", regObj, userObj);
            certQty = Convert.ToInt32(cTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "C";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "10";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 10);
        }
        if (bTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("B", regObj, userObj);
            certQty = Convert.ToInt32(bTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "B";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "5";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 5);
        }
        if (aTextBox.Text != "")
        {
            certNo  = opendMFDAO.GetMaxCertNo("A", regObj, userObj);
            certQty = Convert.ToInt32(aTextBox.Text.Trim());
            for (int i = 0; i < certQty; i++)
            {
                drDinomination                = dtDinomination.NewRow();
                drDinomination["dino"]        = "A";
                drDinomination["cert_no"]     = certNo;
                drDinomination["cert_weight"] = "1";
                dtDinomination.Rows.Add(drDinomination);
                certNo++;
            }
            unitQty = unitQty + (certQty * 1);
        }
        UnitSale unitSaleObj = new UnitSale();

        if (unitQty == 0)
        {
            unitSaleObj.SaleUnitQty = Convert.ToInt32(renewalUnitsTextBox.Text);
            dtDinomination          = opendMFDAO.dtDinomination(unitSaleObj.SaleUnitQty, regObj, userObj);
            dinoGridView.DataSource = dtDinomination;
            dinoGridView.DataBind();
            Session["dtDinomination"] = dtDinomination;
        }
        else if (unitQty > 0)
        {
            if (Convert.ToInt32(renewalUnitsTextBox.Text) != unitQty)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert ('Unit Quantity and Dinomination Quantity is not Equal');", true);
                dtDinomination          = new DataTable();;
                dinoGridView.DataSource = dtDinomination;
                dinoGridView.DataBind();
                //Session["dtDinomination"] = dtDinomination;
            }
            else
            {
                dinoGridView.DataSource = dtDinomination;
                dinoGridView.DataBind();
                Session["dtDinomination"] = dtDinomination;
            }
        }
    }
    protected void addListButton_Click(object sender, EventArgs e)
    {
        UnitHolderRegistration regObj = new UnitHolderRegistration();

        regObj.FundCode      = fundCodeTextBox.Text;
        regObj.BranchCode    = branchCodeTextBox.Text;
        regObj.RegIsCIP      = saleTypeDropDownList.SelectedValue.ToString().ToUpper();
        dinoGridView.Visible = true;
        int       unitQty         = 0;
        int       certNo          = 0;
        DataTable dtDinomination  = opendMFDAO.getTableDinomination();
        DataRow   drDinomination  = dtDinomination.NewRow();
        int       certQty         = 0;
        int       saleLimitLower  = unitSaleBLObj.SaleLimitLower(regObj);
        long      saleLimmitUpper = unitSaleBLObj.SaleLimitUpper(regObj);

        if (saleLimitLower > Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()) && saleTypeDropDownList.SelectedValue.ToString() == "SL")
        {
            dtDinomination          = new DataTable();;
            dinoGridView.DataSource = dtDinomination;
            dinoGridView.DataBind();
            unitQtyTextBox.Focus();
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Sale Unit Quantity can not less than " + saleLimitLower.ToString() + "');", true);
        }
        else if (saleLimmitUpper < Convert.ToInt32(unitQtyTextBox.Text.Trim().ToString()) && saleTypeDropDownList.SelectedValue.ToString() == "SL")
        {
            dtDinomination          = new DataTable();;
            dinoGridView.DataSource = dtDinomination;
            dinoGridView.DataBind();
            unitQtyTextBox.Focus();
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert('Sale Unit Quantity can not greater than " + saleLimmitUpper.ToString() + " Pleas Contact  AMCL Head Office to increase sale unit limit');", true);
        }
        else
        {
            if (string.Compare(regObj.FundCode.ToString(), "CFUF") == 0 || string.Compare(regObj.FundCode.ToString(), "IUF") == 0)
            {
                if (lTextBox.Text != "")
                {
                    certNo  = opendMFDAO.GetMaxCertNo("L", regObj, userObj);
                    certQty = Convert.ToInt32(lTextBox.Text.Trim());
                    for (int i = 0; i < certQty; i++)
                    {
                        drDinomination                = dtDinomination.NewRow();
                        drDinomination["dino"]        = "L";
                        drDinomination["cert_no"]     = certNo;
                        drDinomination["cert_weight"] = "20000";
                        dtDinomination.Rows.Add(drDinomination);
                        certNo++;
                    }
                    unitQty = unitQty + (certQty * 20000);
                }
            }
            if (string.Compare(regObj.FundCode.ToString(), "BDF") == 0 || string.Compare(regObj.FundCode.ToString(), "CFUF") == 0 || string.Compare(regObj.FundCode.ToString(), "IUF") == 0)
            {
                if (kTextBox.Text != "")
                {
                    certNo  = opendMFDAO.GetMaxCertNo("K", regObj, userObj);
                    certQty = Convert.ToInt32(kTextBox.Text.Trim());
                    for (int i = 0; i < certQty; i++)
                    {
                        drDinomination                = dtDinomination.NewRow();
                        drDinomination["dino"]        = "K";
                        drDinomination["cert_no"]     = certNo;
                        drDinomination["cert_weight"] = "10000";
                        dtDinomination.Rows.Add(drDinomination);
                        certNo++;
                    }
                    unitQty = unitQty + (certQty * 10000);
                }
            }
            if (jTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("J", regObj, userObj);
                certQty = Convert.ToInt32(jTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "J";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "5000";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 5000);
            }
            if (iTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("I", regObj, userObj);
                certQty = Convert.ToInt32(iTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "I";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "1000";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 1000);
            }
            if (hTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("H", regObj, userObj);
                certQty = Convert.ToInt32(hTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "H";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "500";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 500);
            }
            if (gTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("G", regObj, userObj);
                certQty = Convert.ToInt32(gTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "G";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "250";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 250);
            }
            if (fTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("F", regObj, userObj);
                certQty = Convert.ToInt32(fTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "F";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "100";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 100);
            }
            if (eTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("E", regObj, userObj);
                certQty = Convert.ToInt32(eTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "E";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "50";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 50);
            }
            if (dTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("D", regObj, userObj);
                certQty = Convert.ToInt32(dTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "D";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "20";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 20);
            }
            if (cTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("C", regObj, userObj);
                certQty = Convert.ToInt32(cTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "C";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "10";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 10);
            }
            if (bTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("B", regObj, userObj);
                certQty = Convert.ToInt32(bTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "B";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "5";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 5);
            }
            if (aTextBox.Text != "")
            {
                certNo  = opendMFDAO.GetMaxCertNo("A", regObj, userObj);
                certQty = Convert.ToInt32(aTextBox.Text.Trim());
                for (int i = 0; i < certQty; i++)
                {
                    drDinomination                = dtDinomination.NewRow();
                    drDinomination["dino"]        = "A";
                    drDinomination["cert_no"]     = certNo;
                    drDinomination["cert_weight"] = "1";
                    dtDinomination.Rows.Add(drDinomination);
                    certNo++;
                }
                unitQty = unitQty + (certQty * 1);
            }
            UnitSale unitSaleObj = new UnitSale();
            if (unitQty == 0)
            {
                unitSaleObj.SaleUnitQty = Convert.ToInt32(unitQtyTextBox.Text);
                dtDinomination          = opendMFDAO.dtDinomination(unitSaleObj.SaleUnitQty, regObj, userObj);
                dinoGridView.DataSource = dtDinomination;
                dinoGridView.DataBind();
                Session["dtDinomination"] = dtDinomination;
            }
            else if (unitQty > 0)
            {
                if (Convert.ToInt32(unitQtyTextBox.Text) != unitQty)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "alert ('Unit Quantity and Denomination Quantity is not Equal');", true);
                    dtDinomination          = new DataTable();;
                    dinoGridView.DataSource = dtDinomination;
                    dinoGridView.DataBind();
                }
                else
                {
                    dinoGridView.DataSource = dtDinomination;
                    dinoGridView.DataBind();
                    Session["dtDinomination"] = dtDinomination;
                }
            }
        }
    }