protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            if (grdBookDetails.Rows.Count == 0)
            {
                MessageBox("Kindly fill Book details");
                txtsalemanCode.Focus();
                return;
            }
            if (txtTrasnport.Text == "")
            {
                MessageBox("Kindly Select Transpoter");
                txtTrasnport.Focus();
                return;
            }
            else
            {
                Other_Z.OtherBAL.SpecimanCN _objSepciman = new Other_Z.OtherBAL.SpecimanCN();
                Other_Z.OtherBAL            objbal       = new Other_Z.OtherBAL();
                string CNDate = txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0] + "/" + txtCNDate.Text.Split('/')[2];
                _objSepciman.GCN           = Convert.ToInt32(txtGCN.Text == "" ? "0" : txtGCN.Text);
                _objSepciman.SCN           = Convert.ToInt32(txtSCN.Text == "" ? "0" : txtSCN.Text);
                _objSepciman.CNDate        = Convert.ToDateTime(CNDate);
                _objSepciman.LrNo          = Convert.ToInt32(txtlrno.Text == "" ? "0" : txtlrno.Text);
                _objSepciman.SalesmanId    = txtsalemanCode.Text.Split(':')[0];
                _objSepciman.FY            = Convert.ToInt32(strFY);
                _objSepciman.SpInstruction = txtspInstruct.Text.Trim();
                _objSepciman.CreatedBy     = Convert.ToString(Session["UserName"]);;
                _objSepciman.XmlData       = SaveSpecimanDetails();
                // SaveSpecimanDetails(1);
                _objSepciman.BooksetId    = Convert.ToInt32(DDLSelectSet.SelectedValue);
                _objSepciman.BooksetQty   = Convert.ToInt32(txtsetqty.Text);
                _objSepciman.TrasportCode = txtTrasnport.Text.Split(':')[0];

                objbal.SaveReturnSpeciman(_objSepciman);

                // _objSepciman.ChallanDate = Convert.ToDateTime(ChallanDate);
                // string ordno = txtorder.Text.Trim();
                //if (ordno == "")
                //{
                //    ordno = "0";
                //}
                //  _objSepciman.OrderNo = txtorder.Text.Trim();
                // _objSepciman.OrderDate = Convert.ToDateTime(OrderDate);


                //_objSepciman.IsActive = true;
                //_objSepciman.IsDeleted = false;

                //  _objSepciman.Description = Description;


                //_objSepciman.Save(out DocNo, 1, out DocNewNo);
                // _objSepciman.Save(out DocNo);
                //txtGCN.Text = Convert.ToString(DocNo);


                //  MessageBox("Record saved successfully \\r\\n Documennt no.  " );
                MessageBox("Record saved successfully ");


                //lblmsg.Text = "Last saved Document no. : " + txtGCN.Text;
                txtGCN.Text               = "";
                txtSCN.Text               = "";
                Session["tempBookData"]   = null;
                grdBookDetails.DataSource = null;
                grdBookDetails.DataBind();
                upGridData.Update();
                DDLSelectSet.SelectedValue = "0";
                Description = "";
            }
        }
        catch (Exception ex)
        {
            string ermsg = ex.Message.ToString();
        }
    }
    private void Save(string Flag)
    {
        try
        {
            if (grdBookDetails.Rows.Count == 0)
            {
                MessageBox("Kindly fill Book details");
            }
            if (txtTrasnport.Text == "")
            {
                MessageBox("Kindly Select Transpoter");
                txtTrasnport.Focus();
                return;
            }
            else
            {
                Other_Z.OtherBAL.SpecimanCN _objSepciman = new Other_Z.OtherBAL.SpecimanCN();
                Other_Z.OtherBAL            objbal       = new Other_Z.OtherBAL();
                string CNDate = txtCNDate.Text.Split('/')[1] + "/" + txtCNDate.Text.Split('/')[0] + "/" + txtCNDate.Text.Split('/')[2];
                _objSepciman.GCN           = Convert.ToInt32(txtGCN.Text == "" ? "0" : txtGCN.Text);
                _objSepciman.SCN           = Convert.ToInt32(txtSCN.Text == "" ? "0" : txtSCN.Text);
                _objSepciman.CNDate        = Convert.ToDateTime(CNDate);
                _objSepciman.LrNo          = Convert.ToInt32(txtlrno.Text == "" ? "0" : txtlrno.Text);
                _objSepciman.SalesmanId    = txtsalemanCode.Text.Split(':')[0];
                _objSepciman.FY            = Convert.ToInt32(strFY);
                _objSepciman.SpInstruction = txtspInstruct.Text.Trim();
                _objSepciman.CreatedBy     = Convert.ToString(Session["UserName"]);;
                _objSepciman.XmlData       = SaveSpecimanDetails();
                // SaveSpecimanDetails(1);
                _objSepciman.BooksetId = Convert.ToInt32(DDLSelectSet.SelectedValue);
                if (txtsetqty.Text.Trim() != "")
                {
                    _objSepciman.BooksetQty = Convert.ToInt32(txtsetqty.Text);
                }
                else
                {
                    _objSepciman.BooksetQty = 0;
                }
                _objSepciman.TrasportCode = txtTrasnport.Text.Split(':')[0];
                int insertno = 0;
                objbal.SaveReturnSpeciman(_objSepciman, out insertno);
                MessageBox("Record saved successfully Document No : " + insertno.ToString());

                if (Flag == "print")
                {
                    Page.ClientScript.RegisterStartupScript(
                        this.GetType(), "OpenWindow", "window.open('CNSpecimanPrint.aspx?docno=" + insertno.ToString() + "');", true);
                }
                ClearForm();

                // _objSepciman.ChallanDate = Convert.ToDateTime(ChallanDate);
                // string ordno = txtorder.Text.Trim();
                //if (ordno == "")
                //{
                //    ordno = "0";
                //}
                //  _objSepciman.OrderNo = txtorder.Text.Trim();
                // _objSepciman.OrderDate = Convert.ToDateTime(OrderDate);


                //_objSepciman.IsActive = true;
                //_objSepciman.IsDeleted = false;

                //  _objSepciman.Description = Description;


                //_objSepciman.Save(out DocNo, 1, out DocNewNo);
                // _objSepciman.Save(out DocNo);
                //txtGCN.Text = Convert.ToString(DocNo);


                //  MessageBox("Record saved successfully \\r\\n Documennt no.  " );



                //lblmsg.Text = "Last saved Document no. : " + txtGCN.Text;
            }
        }
        catch (Exception ex)
        {
            string ermsg = ex.Message.ToString();
        }
    }