protected void grdSchooldetails_RowEditing(object sender, GridViewEditEventArgs e)
    {
        Session["schoolAllotment"] = null;
        pnlSchooldetails.Visible   = true;
        grdSchooldetails.Visible   = false;
        PnlDashboard.Visible       = false;
        LblOriginalQty.Text        = ((Label)grdSchooldetails.Rows[e.NewEditIndex].FindControl("lblReceivedqty")).Text;
        LblBookName.Text           = ((Label)grdSchooldetails.Rows[e.NewEditIndex].FindControl("lblBookname")).Text;
        lblSpDetailid.Text         = ((Label)grdSchooldetails.Rows[e.NewEditIndex].FindControl("lblSpecimenDetailID")).Text;
        lblRemainingQuantity.Text  = ((Label)grdSchooldetails.Rows[e.NewEditIndex].FindControl("lblremain")).Text;
        EmpCode = DDLSalesman.SelectedValue.ToString();
        //DDlSelectSchool.DataSource = Customer_cs.GetSchool_Names(EmpCode);
        //DDlSelectSchool.DataBind();
        GrdPreviousallot.DataSource = Specimen_AllotQty_To_Customer.Get_AllotedSpecimenDetailId(Convert.ToInt32(lblSpDetailid.Text));
        GrdPreviousallot.DataBind();
        pnlSchooldetails.Visible = true;

        BtnBack.Visible            = true;
        Session["schoolAllotment"] = null;
        int Totalqty = Convert.ToInt32(LblOriginalQty.Text);

        ChkQuantity = Convert.ToInt32(lblRemainingQuantity.Text);
        if (ChkQuantity > 0)
        {
            txtqnty.Visible = true;
            btnadd.Visible  = true;
            //DDlSelectSchool.Visible = true;
            lbl2.Visible = true;
        }
        else
        {
            txtqnty.Visible = false;
            btnadd.Visible  = false;
            //  DDlSelectSchool.Visible = false;
            lbl2.Visible = false;
        }
        foreach (GridViewRow row in GrdPreviousallot.Rows)
        {
            int Quantity = Convert.ToInt32(((Label)row.FindControl("LblQuantity")).Text);
            Qty = Qty + Quantity;
        }
        sum = sum + Qty;

        demolabel.Text = Convert.ToString(sum);


        Session["schoolAllotment"] = null;
        int sum1 = Convert.ToInt32(demolabel.Text);

        remainingQty = Totalqty - sum1;
        lblRemainingQuantity.Text = Convert.ToString(remainingQty);
        if (sum1 >= Totalqty)
        {
            BtnSaveAllotDetails.Visible = false;
        }
        else
        {
        }
        filter.Visible = false;
    }
    public void BindDashboardQty()
    {
        EmpCode = DDLSalesman.SelectedItem.Value.ToString();
        DataTable dt = new DataTable();

        dt                    = Specimen_AllotQty_To_Customer.Get_DashBoardAllotQty(EmpCode).Tables[0];
        lnkorder.Text         = dt.Rows[0][0].ToString();
        lnkReceive.Text       = dt.Rows[0][1].ToString();
        lnkAllot.Text         = dt.Rows[0][2].ToString();
        lnkPending.Text       = dt.Rows[0][3].ToString();
        lnkCustomerCount.Text = dt.Rows[0][4].ToString();
    }
    protected void BtnSaveAllotDetails_Click(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            int Totalqty = Convert.ToInt32(LblOriginalQty.Text);
            foreach (GridViewRow row in GridView1.Rows)
            {
                int Quantity = Convert.ToInt32(((Label)row.FindControl("LblQuantity")).Text);
                Qty = Qty + Quantity;
            }
            sum = sum + Qty;


            foreach (GridViewRow row in GrdPreviousallot.Rows)
            {
                int Quantity = Convert.ToInt32(((Label)row.FindControl("LblQuantity")).Text);
                Qty1 = Qty1 + Quantity;
            }
            sum2 = sum2 + Qty1;

            Totalsum = sum2 + sum;

            demolabel.Text = Convert.ToString(Totalsum);
            int sum1 = Convert.ToInt32(demolabel.Text);

            if (Totalqty < sum1)
            {
                MessageBox("You can not allot this book now");
            }
            else
            {
                DataTable dt = new DataTable();
                dt = (DataTable)Session["schoolAllotment"];
                Specimen_AllotQty_To_Customer _objAD = new Specimen_AllotQty_To_Customer();
                foreach (GridViewRow row in GridView1.Rows)
                {
                    _objAD.AllotCustID      = 0;
                    _objAD.SpecimenDetailId = Convert.ToInt32(lblSpDetailid.Text);
                    _objAD.CustID           = Convert.ToInt32(((Label)row.FindControl("LblSchoolId")).Text);
                    _objAD.AllotQty         = Convert.ToInt32(((Label)row.FindControl("LblQuantity")).Text);
                    _objAD.CreatedBy        = "Admin";
                    _objAD.IsDelete         = false;
                    _objAD.Save();
                }
                MessageBox("Your books are alloted sucessfully.");
                Session["schoolAllotment"] = null;
                txtqnty.Text = "";
                GrdPreviousallot.DataSource = Specimen_AllotQty_To_Customer.Get_AllotedSpecimenDetailId(Convert.ToInt32(lblSpDetailid.Text));
                GrdPreviousallot.DataBind();
                GridView1.Visible = false;

                BtnSaveAllotDetails.Visible = false;
                BtnSaveAllotDetails.Enabled = false;
                ChkQuantity2 = Convert.ToInt32(lblRemainingQuantity.Text);
                if (ChkQuantity3 > 0)
                {
                    txtqnty.Visible         = true;
                    btnadd.Visible          = true;
                    DDlSelectSchool.Visible = true;
                    lbl2.Visible            = true;
                }
                else
                {
                    txtqnty.Visible         = false;
                    btnadd.Visible          = false;
                    DDlSelectSchool.Visible = false;
                    lbl2.Visible            = false;
                }
            }
        }
    }