protected void grdBookDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DCDetails _objdcd = new DCDetails();

        DCDid = Convert.ToInt32(((Label)grdBookDetails.Rows[e.RowIndex].FindControl("lblDCDetailID")).Text);

        try
        {
            if (DCDid != 0)
            {
                _objdcd.DCDetailID = DCDid;
                _objdcd.IsActive   = false;
                _objdcd.Amount     = 0;
                _objdcd.Rate       = 0;
                _objdcd.Discount   = 0;

                _objdcd.Save();
            }
            DataTable dt1 = new DataTable();
            dt1 = (DataTable)Session["tempDCData"];
            dt1.Rows[e.RowIndex].Delete();
            grdBookDetails.DataSource = dt1;
            grdBookDetails.DataBind();
            Session["tempDCData"] = dt1;
            loder("Successfully Deleted...");
        }
        catch
        {
        }
    }
    public void SaveDCDetails(int docNo)
    {
        DCDetails _objDCD = new DCDetails();

        try
        {
            foreach (GridViewRow row in grdBookDetails.Rows)
            {
                _objDCD.DCDetailID = Convert.ToInt32(((Label)row.FindControl("lblDCDetailID")).Text);
                _objDCD.DocumentNo = docNo;
                _objDCD.BookCode   = ((Label)row.FindControl("lblBookCode")).Text;
                _objDCD.BookName   = ((Label)row.FindControl("lblBookName")).Text;
                _objDCD.Standard   = ((Label)row.FindControl("lblStandard")).Text;
                _objDCD.Medium     = ((Label)row.FindControl("lblMedium")).Text;
                Reqty            = Convert.ToInt32(((TextBox)row.FindControl("txtquty")).Text);
                givqty           = Convert.ToInt32(((Label)row.FindControl("lblgivedqty")).Text);
                _objDCD.Quantity = Reqty + givqty;
                // string DDate = ((TextBox)row.FindControl("txtDeldate")).Text;
                // DDate = DDate.Split('/')[1] + "/" + DDate.Split('/')[0] + "/" + DDate.Split('/')[2];
                string DDate = txtDeliverydte.Text.Split('/')[1] + "/" + txtDeliverydte.Text.Split('/')[0] + "/" + txtDeliverydte.Text.Split('/')[2];

                _objDCD.DeliveryDate = Convert.ToDateTime(DDate);
                _objDCD.Rate         = Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text);
                _objDCD.Discount     = Convert.ToDecimal(((TextBox)row.FindControl("txtDiscount")).Text);
                discount             = Convert.ToDecimal(((TextBox)row.FindControl("txtDiscount")).Text);

                amt       = Convert.ToDecimal(((TextBox)row.FindControl("txtrate")).Text) * Reqty;
                Tdiscount = amt * (discount / 100);
                amt       = amt - Tdiscount;

                if (((Label)row.FindControl("lblAmt")).Text != "")
                {
                    _objDCD.Amount = Convert.ToDecimal(amt);
                }
                else
                {
                    _objDCD.Amount = 0;
                }



                //_objDCD.Publisher = ((Label)row.FindControl("lblPublisher")).Text;
                _objDCD.CreatedBy = Convert.ToString(Session["UserName"]);
                _objDCD.IsActive  = true;
                _objDCD.Save();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }