protected void DDLtargetperson_SelectedIndexChanged(object sender, EventArgs e)
    {
        string ID = TargetMaster.get_Target_validateh_valid(Convert.ToInt32(DDLtargetperson.SelectedItem.Value), strFY);

        if (ID.ToLower() != "not set!")
        {
            MessageBox("Already has target");
            DDLtargetperson.Focus();
            DDLtargetperson.SelectedIndex = 0;
        }
        else
        {
            txttargetamt.Focus();
        }
    }
    protected void DDLsuperzone_SelectedIndexChanged(object sender, EventArgs e)
    {
        string strsts = TargetMaster.get_Target_validateh_valid(Convert.ToInt32(DDLsuperzone.SelectedItem.Value), strFY);

        lblDetails.Text = "Target Amount is " + strsts;


        if (strsts.ToLower() == "not set!")
        {
            btn_Save.Visible = false;
        }
        else
        {
            btn_Save.Visible = true;
        }
        getDDLdata();
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        string from = txtstartDate.Text.Split('/')[1] + "/" + txtstartDate.Text.Split('/')[0] + "/" + txtstartDate.Text.Split('/')[2];
        string To   = txtendate.Text.Split('/')[1] + "/" + txtendate.Text.Split('/')[0] + "/" + txtendate.Text.Split('/')[2];

        fdate = Convert.ToDateTime(from);
        tdate = Convert.ToDateTime(To);
        if (fdate > tdate)
        {
            MessageBox("Start Date Should be Greater than End Date");
            txtstartDate.Focus();
        }
        else
        {
            try
            {
                TargetMaster _objtarget = new TargetMaster();
                if (lblID.Text != "0")
                {
                    _objtarget.TargetId = Convert.ToInt32(lblID.Text.Trim());
                }
                else
                {
                    _objtarget.TargetId = 0;
                }
                _objtarget.TargetPersonId = Convert.ToInt32(DDLtargetperson.SelectedItem.Value);

                _objtarget.TargetAmt = Convert.ToDecimal(txttargetamt.Text.Trim());
                string StartDate = txtstartDate.Text.Split('/')[1] + "/" + txtstartDate.Text.Split('/')[0] + "/" + txtstartDate.Text.Split('/')[2];
                string endDate   = txtendate.Text.Split('/')[1] + "/" + txtendate.Text.Split('/')[0] + "/" + txtendate.Text.Split('/')[2];
                _objtarget.TargetStartDate = Convert.ToDateTime(StartDate);
                _objtarget.TargetEndDate   = Convert.ToDateTime(endDate);
                _objtarget.IsActive        = true;
                _objtarget.FY        = Convert.ToInt32(strFY);
                _objtarget.CreatedBy = Session["UserName"].ToString();
                string ID = TargetMaster.get_Target_validateh_valid(Convert.ToInt32(DDLtargetperson.SelectedItem.Value), strFY);
                if (ID.ToLower() != "not set!" && lblID.Text == "0")
                {
                    MessageBox("Already has target");
                    DDLtargetperson.Focus();
                    DDLtargetperson.SelectedIndex = 0;
                }
                else
                {
                    _objtarget.Save();
                    MessageBox(Constants.save);
                    if (btn_Save.Text == "Update")
                    {
                        pnlTargetdetails.Visible    = true;
                        PnlTarget.Visible           = false;
                        grdtargetDetails.DataSource = BindGvTargetDetail(Convert.ToInt32(strFY));
                        grdtargetDetails.DataBind();
                        btn_Save.Text    = "Save";
                        btn_Save.Visible = false;
                    }
                    else
                    {
                        pnlTargetdetails.Visible      = false;
                        PnlTarget.Visible             = true;
                        btn_Save.Text                 = "Update";
                        txttargetamt.Text             = "";
                        txtstartDate.Text             = "";
                        txtendate.Text                = "";
                        DDLtargetperson.SelectedValue = "0";
                    }
                }
            }

            catch { }
        }
    }