protected void grdCustDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        bool _objct = new CustomerToTransport().isDelete("customer", (((Label)grdCustDetails.Rows[e.RowIndex].FindControl("lblCustID")).Text));

        if (_objct)
        {
            Customer_cs _objCM = new Customer_cs();
            _objCM.CustID = Convert.ToInt32(((Label)grdCustDetails.Rows[e.RowIndex].FindControl("lblCustID")).Text);

            _objCM.CustCode = ((Label)grdCustDetails.Rows[e.RowIndex].FindControl("lblCustCode")).Text;
            _objCM.CustName = ((Label)grdCustDetails.Rows[e.RowIndex].FindControl("lblCustName")).Text;

            _objCM.IsActive   = Convert.ToBoolean(false);
            _objCM.IsDeleted  = Convert.ToBoolean(true);
            _objCM.IsDeleted1 = Convert.ToBoolean(true);
            try
            {
                _objCM.Update();
                MessageBox("Your record is Deleted");

                PnlDetails.Visible = true;
                PnlAdd.Visible     = false;
            }
            catch
            {
            }
        }
        else
        {
            MessageBox("You Can not Delete This Customer");
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // DdlSection.Text = "----";

        try
        {
            //string Area = TxtArea.Text.Split(':')[0].Trim();
            Customer_cs _objCust = new Customer_cs();
            _objCust.CustID       = Convert.ToInt32(LblCustId.Text);
            _objCust.CustCode     = TxtCustCode.Text.Trim();
            _objCust.ShortForm    = TxtShortForm.Text.Trim();
            _objCust.FamilyCode   = TxtFamilyCode.Text.Trim();
            _objCust.Address      = TxtAddress.Text.Trim();
            _objCust.Zip          = TxtZip.Text.Trim();
            _objCust.Phone1       = TxtPhone1.Text.Trim();
            _objCust.Phone2       = TxtPhone2.Text.Trim();
            _objCust.EmailID      = TxtEmailID.Text.Trim();
            _objCust.CUSTOMERTYPE = TxtCustomerType.Text.Trim();
            _objCust.IsDeleted    = false;
            _objCust.IsActive     = true;
            _objCust.CreatedBy    = Convert.ToString(Session["UserName"]);
            _objCust.CustName     = TxtCustName.Text.Trim();
            _objCust.ZoneID       = Convert.ToInt32(DDLzone.SelectedValue);
            _objCust.SuperZoneID  = Convert.ToInt32(DDLsuperzone.SelectedValue);
            _objCust.AreaZoneID   = Convert.ToInt32(DDLareazone.SelectedValue);
            _objCust.AreaID       = Convert.ToInt32(DDLarea.SelectedValue);
            _objCust.DMID         = Convert.ToInt32(ddLStates.SelectedValue);
            _objCust.City         = Convert.ToInt32(ddlCity.SelectedValue);
            _objCust.CustRating   = Convert.ToInt32(DdlCustRating.SelectedValue);
            string TxtPrincipalDOB1 = "";
            string TxtKeyPersonDOB1 = "";

            try
            {
                TxtPrincipalDOB1 = TxtPrincipalDOB.Text.Split('/')[1] + "/" + TxtPrincipalDOB.Text.Split('/')[0] + "/" + TxtPrincipalDOB.Text.Split('/')[2];
                TxtKeyPersonDOB1 = TxtKeyPersonDOB.Text.Split('/')[1] + "/" + TxtKeyPersonDOB.Text.Split('/')[0] + "/" + TxtKeyPersonDOB.Text.Split('/')[2];
            }
            catch
            {
            }

            if (LblCustId.Text == "0")
            {
                _objCust.Save(out CID);
                // TxtCustId.Text = Convert.ToString(CID);
                string          Medium          = TxtMedium.Text.Split(':')[0].Trim();
                CustomerDetails _objCustDetails = new CustomerDetails();
                _objCustDetails.CustId      = CID;
                _objCustDetails.CustCode    = TxtCustCode.Text.Trim();
                _objCustDetails.CreditLimit = TxtCreditLimit.Text.Trim();
                // _objCustDetails.Creditdays = txtcreditdays.Text.Trim();
                _objCustDetails.BlackList       = ChkBlacklist.Checked;
                _objCustDetails.CreatedBy       = Convert.ToString(Session["UserName"]);
                _objCustDetails.PrincipalName   = TxtPrincipalName.Text.Trim();
                _objCustDetails.PrincipalMobile = TxtPrincipalMobile.Text.Trim();
                _objCustDetails.PrincipalDOB    = TxtPrincipalDOB1;
                _objCustDetails.KeyPersonName   = TxtKeyPersonName.Text.Trim();
                _objCustDetails.KeyPersonMobile = TxtKeyPersonMobile.Text.Trim();
                _objCustDetails.KeyPersonDOB    = TxtKeyPersonDOB.Text.Trim();
                _objCustDetails.AdditinalDis    = TxtAdditinalDis.Text.Trim();
                _objCustDetails.VIPRemark       = TxtVIPRemark.Text.Trim();
                _objCustDetails.SectionID       = 0;
                //_objCustDetails.SectionID = Convert.ToInt32(DdlSection.SelectedValue);
                _objCustDetails.Medium = Medium;
                _objCustDetails.Save();
                grdCustDetails.Visible = true;
                PnlDetails.Visible     = true;
                MessageBox("Record saved successfully");
                if (btnSave.Text == "Update")
                {
                    PnlDetails.Visible = true;
                    PnlAdd.Visible     = false;
                    btnSave.Visible    = false;
                    filter.Visible     = true;
                }
                else
                {
                    PnlDetails.Visible = false;
                    PnlAdd.Visible     = true;
                    btnSave.Visible    = true;
                }
            }
            else
            {
                string Medium = TxtMedium.Text.Split(':')[0].Trim();
                _objCust.CustID       = Convert.ToInt32(LblCustId.Text);
                _objCust.CustDetailID = Convert.ToInt32(LblCustDetailID1.Text);
                if (TxtCreditLimit.Text == "")
                {
                    TxtCreditLimit.Text = "0";
                }
                _objCust.CreditLimit     = Convert.ToInt32(TxtCreditLimit.Text.Trim());
                _objCust.CreditDays      = txtcreditdays.Text.Trim();
                _objCust.BlackList       = ChkBlacklist.Checked;
                _objCust.IsDeleted1      = false;
                _objCust.PrincipalName   = TxtPrincipalName.Text.Trim();
                _objCust.PrincipalMobile = TxtPrincipalMobile.Text.Trim();
                _objCust.PrincipalDOB    = TxtPrincipalDOB.Text.Trim();
                _objCust.KeyPersonName   = TxtKeyPersonName.Text.Trim();
                _objCust.KeyPersonMobile = TxtKeyPersonMobile.Text.Trim();
                _objCust.KeyPersonDOB    = TxtKeyPersonDOB.Text.Trim();
                _objCust.AdditinalDis    = TxtAdditinalDis.Text.Trim();
                _objCust.VIPRemark       = TxtVIPRemark.Text.Trim();

                //_objCust.SectionID = Convert.ToInt32(DdlSection.SelectedValue);
                _objCust.SectionID = 0;
                _objCust.Medium    = Medium;

                _objCust.Update();
                DataView dv1 = new DataView(BindGvCustDetail().Table);
                Session["data"]           = dv1;
                grdCustDetails.DataSource = dv1;
                grdCustDetails.DataBind();

                MessageBox("Record updated successfully");
                TxtCustCode.Enabled = true;
                if (btnSave.Text.ToLower() == "update")
                {
                    PnlDetails.Visible = true;
                    PnlAdd.Visible     = false;
                    btnSave.Visible    = false;
                    filter.Visible     = true;
                }
                else
                {
                    PnlDetails.Visible = false;
                    PnlAdd.Visible     = true;
                    btnSave.Visible    = true;
                }
            }
            TxtCustCode.Text            = "";
            TxtShortForm.Text           = "";
            TxtFamilyCode.Text          = "";
            TxtAddress.Text             = "";
            TxtZip.Text                 = "";
            TxtPhone1.Text              = "";
            TxtPhone2.Text              = "";
            TxtEmailID.Text             = "";
            TxtCustName.Text            = "";
            TxtCreditLimit.Text         = "";
            TxtPrincipalName.Text       = "";
            TxtPrincipalMobile.Text     = "";
            TxtPrincipalDOB.Text        = "";
            TxtKeyPersonName.Text       = "";
            TxtKeyPersonMobile.Text     = "";
            TxtKeyPersonDOB.Text        = "";
            TxtAdditinalDis.Text        = "";
            TxtVIPRemark.Text           = "";
            TxtMedium.Text              = "";
            TxtCustomerType.Text        = "";
            DDLzone.SelectedValue       = "0";
            DDLareazone.SelectedValue   = "0";
            DDLarea.SelectedValue       = "0";
            ddLStates.SelectedValue     = "0";
            DDLsuperzone.SelectedValue  = "0";
            DdlCustRating.SelectedValue = "0";
        }
        catch (SqlException ex)
        {
            Response.Write(ex.Message.ToString());
        }
        catch (Exception ex1)
        {
            Response.Write(ex1.Message.ToString());
        }
    }