protected void btnSave_Click(object sender, EventArgs e)
    {
        clsIndentItems obj = new clsIndentItems();

        obj.IndentID = Convert.ToInt32(Request.QueryString["IndentID"]);
        foreach (GridViewRow dr in grd.Rows)
        {
            TextBox     txtLogNo        = dr.FindControl("txtLogNo") as TextBox;
            TextBox     txtPartNo       = dr.FindControl("txtPartNo") as TextBox;
            HiddenField hdPartID        = dr.FindControl("hdPartID") as HiddenField;
            TextBox     txtItem         = dr.FindControl("txtItem") as TextBox;
            TextBox     txtCurrentStock = dr.FindControl("txtCurrentStock") as TextBox;
            TextBox     txtQuantity     = dr.FindControl("txtQuantity") as TextBox;
            HiddenField hdPrevQuantity  = dr.FindControl("hdPrevQuantity") as HiddenField;
            TextBox     txtUOM          = dr.FindControl("txtUOM") as TextBox;
            TextBox     txtRemark       = dr.FindControl("txtRemark") as TextBox;
            LinkButton  lnkDelete       = dr.FindControl("lnkDelete") as LinkButton;
            if (hdPartID.Value == "-1")
            {
                if (txtPartNo.Text != "" && txtItem.Text != "" && Convert.ToInt32(txtQuantity.Text) != 0)
                {
                    obj.Op           = 1;
                    obj.LogNo        = txtLogNo.Text;
                    obj.PartNo       = txtPartNo.Text;
                    obj.Particular   = txtItem.Text;
                    obj.CurrentStock = Convert.ToInt32(txtCurrentStock.Text);
                    obj.Quantity     = Convert.ToInt32(txtQuantity.Text);
                    obj.UOM          = txtUOM.Text;
                    obj.Remarks      = txtRemark.Text;
                    obj.IndentItemMaster(obj);
                }
            }
            else
            {
                if (Convert.ToInt32(Request.QueryString["Status"]) == 1)
                {
                    if (txtQuantity.Text != hdPrevQuantity.Value)
                    {
                        obj.Op       = 4;
                        obj.ID       = Convert.ToInt32(grd.DataKeys[dr.RowIndex].Value);
                        obj.Quantity = Convert.ToInt32(txtQuantity.Text);
                        obj.IndentItemMaster(obj);
                        if (Convert.ToInt32(txtCurrentStock.Text) > Convert.ToInt32(txtQuantity.Text))
                        {
                            clsSiteProductParts obSPP = new clsSiteProductParts();
                            obSPP.SiteID          = Convert.ToInt32(Request.QueryString["SiteID"]);
                            obSPP.SiteMachineID   = Convert.ToInt32(Request.QueryString["SiteMachineID"]);
                            obSPP.PartID          = Convert.ToInt32(hdPartID.Value);
                            obSPP.Quantity        = Convert.ToInt32(txtCurrentStock.Text) - Convert.ToInt32(txtQuantity.Text);
                            obSPP.Op              = 1;
                            obSPP.TransactionType = 1;
                            obSPP.Remarks         = "Insert against Indent edit";
                            obSPP.SiteProductParts(obSPP);
                        }
                    }
                }
            }
        }
    }
    protected void grdIndentRef_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        txtIndentRef.Text = grdIndentRef.Rows[e.RowIndex].Cells[0].Text;
        clsIndent objIndent = new clsIndent();

        objIndent.Op    = 7;
        objIndent.RefNo = txtIndentRef.Text.Trim();
        DataTable dtIndent = objIndent.IndentMaster(objIndent).Tables[0];

        if (dtIndent.Rows.Count > 0)
        {
            hdSiteID.Value = dtIndent.Rows[0]["OrderFromID"].ToString();
            ddlSite.Text   = dtIndent.Rows[0]["OrderFromID"].ToString();
        }
        else
        {
        }
        clsIndentItems obj = new clsIndentItems();

        obj.IndentID = Convert.ToInt32(grdIndentRef.DataKeys[e.RowIndex].Value);
        obj.Op       = 2;
        DataTable dt = obj.IndentItemMaster(obj).Tables[0];

        grdIndentItems.DataSource = dt;
        grdIndentItems.DataBind();
        grdIndentRef.Visible = false;
        LoadSiteMachines();
    }
    protected void grd_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        clsIndentItems obj = new clsIndentItems();

        obj.ID = Convert.ToInt32(grd.DataKeys[e.RowIndex].Value);
        obj.Op = 5;
        obj.IndentItemMaster(obj);

        /*Add to items*/
        TextBox             txtLogNo        = grd.Rows[e.RowIndex].FindControl("txtLogNo") as TextBox;
        TextBox             txtPartNo       = grd.Rows[e.RowIndex].FindControl("txtPartNo") as TextBox;
        HiddenField         hdPartID        = grd.Rows[e.RowIndex].FindControl("hdPartID") as HiddenField;
        TextBox             txtItem         = grd.Rows[e.RowIndex].FindControl("txtItem") as TextBox;
        TextBox             txtCurrentStock = grd.Rows[e.RowIndex].FindControl("txtCurrentStock") as TextBox;
        TextBox             txtQuantity     = grd.Rows[e.RowIndex].FindControl("txtQuantity") as TextBox;
        HiddenField         hdPrevQuantity  = grd.Rows[e.RowIndex].FindControl("hdPrevQuantity") as HiddenField;
        TextBox             txtUOM          = grd.Rows[e.RowIndex].FindControl("txtUOM") as TextBox;
        TextBox             txtRemark       = grd.Rows[e.RowIndex].FindControl("txtRemark") as TextBox;
        LinkButton          lnkDelete       = grd.Rows[e.RowIndex].FindControl("lnkDelete") as LinkButton;
        clsSiteProductParts obSPP           = new clsSiteProductParts();

        obSPP.SiteID          = Convert.ToInt32(Request.QueryString["SiteID"]);
        obSPP.SiteMachineID   = Convert.ToInt32(Request.QueryString["SiteMachineID"]);
        obSPP.PartID          = Convert.ToInt32(hdPartID.Value);
        obSPP.Quantity        = Convert.ToInt32(txtCurrentStock.Text) - Convert.ToInt32(txtQuantity.Text);
        obSPP.Op              = 1;
        obSPP.TransactionType = 1;
        obSPP.Remarks         = "Insert against Indent edit";
        obSPP.SiteProductParts(obSPP);
    }
    void SaveIssueList(int IndentID)
    {
        clsIndent obj = new clsIndent();

        obj.ID = IndentID;
        obj.Op = 4;
        DataTable      dt   = obj.IndentMaster(obj).Tables[0];
        clsIndentItems obII = new clsIndentItems();

        obII.IndentID = IndentID;
        obII.Op       = 3;
        DataTable dtItems = obII.IndentItemMaster(obII).Tables[0];

        if (dtItems.Rows.Count > 0)
        {
            /*Add To Issue*/
            clsSitePartIssue obSPI = new clsSitePartIssue();
            obSPI.SiteID        = Convert.ToInt32(dt.Rows[0]["SiteID"]);
            obSPI.SiteMachineID = Convert.ToInt32(dt.Rows[0]["SiteMachineID"]);
            obSPI.IndentRef     = dt.Rows[0]["RefNo"].ToString();
            obSPI.Op            = 1;
            /*Stock Management Entry*/
            clsSiteProductParts obSPP = new clsSiteProductParts();
            obSPP.SiteID          = Convert.ToInt32(dt.Rows[0]["SiteID"]);
            obSPP.SiteMachineID   = Convert.ToInt32(dt.Rows[0]["SiteMachineID"]);
            obSPP.BillRef         = dt.Rows[0]["RefNo"].ToString();
            obSPP.Remarks         = "Issued Against Indent";
            obSPP.Op              = 1;
            obSPP.TransactionType = 2;
            foreach (DataRow dr in dtItems.Rows)
            {
                try
                {
                    obSPI.PartID   = Convert.ToInt32(dr["PartID"]);
                    obSPI.PartNo   = dr["PartNo"].ToString();
                    obSPI.PartName = dr["PartName"].ToString();
                    obSPI.Price    = Convert.ToDouble(dr["Price"]);
                    if (Convert.ToInt32(dr["Quantity"]) > Convert.ToInt32(dr["CurrentStock"]))
                    {
                        obSPI.Quantity = Convert.ToInt32(dr["CurrentStock"]);
                        obSPP.Quantity = Convert.ToInt32(dr["CurrentStock"]);
                    }
                    else
                    {
                        obSPI.Quantity = Convert.ToInt32(dr["Quantity"]);
                        obSPP.Quantity = Convert.ToInt32(dr["Quantity"]);
                    }
                    obSPI.SitePartIssue(obSPI);
                    obSPP.PartID = Convert.ToInt32(dr["PartID"]);
                    try { obSPP.Rate = Convert.ToDouble(dr["Price"]); }
                    catch { }
                    obSPP.Total = obSPP.Rate * obSPP.Quantity;
                    obSPP.SiteProductParts(obSPP);
                }
                catch
                {
                }
            }
        }
    }
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        clsIndent obj = new clsIndent();

        obj.Op         = 10;
        obj.ID         = Convert.ToInt32(Request.QueryString["ID"]);
        obj.Status     = 1;
        obj.ApprovedBy = Convert.ToInt32(hdApprovedBy.Value);
        obj.IndentMaster(obj);
        obj.Op = 4;
        DataTable      dt   = obj.IndentMaster(obj).Tables[0];
        clsIndentItems obII = new clsIndentItems();

        obII.IndentID = Convert.ToInt32(Request.QueryString["ID"]);
        obII.Op       = 3;
        DataTable dtItems = obII.IndentItemMaster(obII).Tables[0];

        if (dtItems.Rows.Count > 0)
        {
            /*Add To Issue*/
            clsSitePartIssue obSPI = new clsSitePartIssue();
            obSPI.SiteID        = Convert.ToInt32(dt.Rows[0]["SiteID"]);
            obSPI.SiteMachineID = Convert.ToInt32(dt.Rows[0]["SiteMachineID"]);
            obSPI.IndentRef     = dt.Rows[0]["RefNo"].ToString();
            obSPI.Op            = 1;
            /*Stock Management Entry*/
            clsSiteProductParts obSPP = new clsSiteProductParts();
            obSPP.SiteID          = Convert.ToInt32(dt.Rows[0]["SiteID"]);
            obSPP.SiteMachineID   = Convert.ToInt32(dt.Rows[0]["SiteMachineID"]);
            obSPP.BillRef         = dt.Rows[0]["RefNo"].ToString();
            obSPP.Remarks         = "Issued Against Indent";
            obSPP.Op              = 1;
            obSPP.TransactionType = 2;
            foreach (DataRow dr in dtItems.Rows)
            {
                obSPI.PartID   = Convert.ToInt32(dr["PartID"]);
                obSPI.PartNo   = dr["PartNo"].ToString();
                obSPI.PartName = dr["PartName"].ToString();
                obSPI.Price    = Convert.ToDouble(dr["Price"]);
                if (Convert.ToInt32(dr["Quantity"]) > Convert.ToInt32(dr["CurrentStock"]))
                {
                    obSPI.Quantity = Convert.ToInt32(dr["CurrentStock"]);
                    obSPP.Quantity = Convert.ToInt32(dr["CurrentStock"]);
                }
                else
                {
                    obSPI.Quantity = Convert.ToInt32(dr["Quantity"]);
                    obSPP.Quantity = Convert.ToInt32(dr["Quantity"]);
                }
                obSPI.SitePartIssue(obSPI);
                obSPP.PartID = Convert.ToInt32(dr["PartID"]);
                try { obSPP.Rate = Convert.ToDouble(dr["Price"]); }
                catch { }
                obSPP.Total = obSPP.Rate * obSPP.Quantity;
                obSPP.SiteProductParts(obSPP);
            }
        }
        LoadOrder();
    }
 void LoadItems()
 {
     try
     {
         clsIndentItems obj = new clsIndentItems();
         obj.IndentID = Convert.ToInt32(Request.QueryString["IndentID"]);
         obj.Op       = 2;
         DataTable dt = obj.IndentItemMaster(obj).Tables[0];
         while (dt.Rows.Count < 20)
         {
             dt.Rows.Add();
             dt.Rows[dt.Rows.Count - 1]["ID"]           = 0;
             dt.Rows[dt.Rows.Count - 1]["PartID"]       = -1;
             dt.Rows[dt.Rows.Count - 1]["CurrentStock"] = 0;
             dt.Rows[dt.Rows.Count - 1]["Quantity"]     = 0;
         }
         dt.Columns.Add("SL");
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             dt.Rows[i]["SL"] = i + 1;
             if (dt.Rows[i]["Photo"] != "")
             {
                 dt.Rows[i]["Photo"] = "~/" + dt.Rows[i]["Photo"];
             }
         }
         grd.DataSource = dt;
         grd.DataBind();
         foreach (GridViewRow dr in grd.Rows)
         {
             LinkButton  lnkDelete = dr.FindControl("lnkDelete") as LinkButton;
             HiddenField hdPartID  = dr.FindControl("hdPartID") as HiddenField;
             if (hdPartID.Value == "-1")
             {
                 lnkDelete.Enabled = false;
             }
             else
             {
                 TextBox txtLogNo = dr.FindControl("txtLogNo") as TextBox;
                 txtLogNo.Enabled = false;
                 TextBox txtPartNo = dr.FindControl("txtPartNo") as TextBox;
                 txtPartNo.Enabled = false;
                 TextBox txtItem = dr.FindControl("txtItem") as TextBox;
                 txtItem.Enabled = false;
                 TextBox txtCurrentStock = dr.FindControl("txtCurrentStock") as TextBox;
                 txtCurrentStock.Enabled = false;
                 TextBox txtUOM = dr.FindControl("txtUOM") as TextBox;
                 txtUOM.Enabled = false;
                 TextBox txtRemark = dr.FindControl("txtRemark") as TextBox;
                 txtRemark.Enabled = false;
             }
         }
     }
     catch {
         Response.Redirect("~/Default.aspx");
     }
 }
    public void SaveIndentItems(int IndentID, string LogNo, string PartNo, string Particular, int CurrentStock, int Quantity, string UOM, string Remarks, string Photo)
    {
        clsIndentItems obj = new clsIndentItems();

        obj.IndentID     = IndentID;
        obj.LogNo        = LogNo;
        obj.PartNo       = PartNo;
        obj.Particular   = Particular;
        obj.CurrentStock = CurrentStock;
        obj.Quantity     = Quantity;
        obj.UOM          = UOM;
        obj.Remarks      = Remarks;
        obj.Photo        = Photo;
        obj.Op           = 1;
        obj.IndentItemMaster(obj);
        Context.Response.Write(JsonConvert.SerializeObject("Saved"));
    }
    public void GetIndentDetail(int IndentID)
    {
        clsIndent obj = new clsIndent();

        obj.ID = IndentID;
        obj.Op = 4;
        DataTable      dtIndent = obj.IndentMaster(obj).Tables[0];
        clsIndentItems obj1     = new clsIndentItems();

        obj1.IndentID = IndentID;
        obj1.Op       = 2;
        DataTable dtIndentItem = obj1.IndentItemMaster(obj1).Tables[0];

        DataTable[] dt = new DataTable[2];
        dt[0] = dtIndent;
        dt[1] = dtIndentItem;
        Context.Response.Write(JsonConvert.SerializeObject(dt));
    }
 void AddTempItemsToIndent(int IndentID)
 {
     foreach (GridViewRow dr in grd.Rows)
     {
         clsIndentItems obj = new clsIndentItems();
         //TextBox txtLogNo = dr.FindControl("txtLogNo") as TextBox;
         TextBox     txtPartNo       = dr.FindControl("txtPartNo") as TextBox;
         TextBox     txtItem         = dr.FindControl("txtItem") as TextBox;
         TextBox     txtCurrentStock = dr.FindControl("txtCurrentStock") as TextBox;
         TextBox     txtQuantity     = dr.FindControl("txtQuantity") as TextBox;
         TextBox     txtUOM          = dr.FindControl("txtUOM") as TextBox;
         TextBox     txtRemark       = dr.FindControl("txtRemark") as TextBox;
         FileUpload  file            = dr.FindControl("file") as FileUpload;
         HiddenField hdPartID        = dr.FindControl("hdPartID") as HiddenField;
         if (((txtPartNo.Text != "" && txtItem.Text != "") || file.HasFile) && Convert.ToInt32(txtQuantity.Text) != 0)
         {
             clsIndentItems objItems = new clsIndentItems();
             objItems.Op       = 1;
             objItems.IndentID = IndentID;
             //objItems.LogNo = txtLogNo.Text;
             objItems.PartNo       = txtPartNo.Text;
             objItems.Particular   = txtItem.Text;
             objItems.CurrentStock = Convert.ToInt32(txtCurrentStock.Text);
             objItems.Quantity     = Convert.ToInt32(txtQuantity.Text);
             objItems.UOM          = txtUOM.Text;
             objItems.Remarks      = txtRemark.Text;
             objItems.Photo        = UploadPhoto(file);
             objItems.IndentItemMaster(objItems);
             if (hdPartID.Value == "0")
             {
                 clsSiteMachines obSM = new clsSiteMachines();
                 obSM.ID = Convert.ToInt32(ddlMachine.SelectedValue);
                 obSM.Op = 5;
                 DataTable dtSM   = obSM.SiteMachines(obSM).Tables[0];
                 clsPart   obPart = new clsPart();
                 obPart.SerialNo  = txtPartNo.Text;
                 obPart.PartName  = txtItem.Text;
                 obPart.MachineID = Convert.ToInt32(dtSM.Rows[0]["SiteMachineID"]);
                 obPart.Op        = 1;
                 obPart.PartMaster(obPart);
             }
         }
     }
 }
    void AddTempItemsToIndent(int IndentID)
    {
        clsTempIndentItems obj = new clsTempIndentItems();

        obj.UserID = Convert.ToInt32(Request.Cookies["User"].Value);
        obj.Op     = 3;
        DataTable dt = obj.TempIndentItems(obj).Tables[0];

        foreach (DataRow dr in dt.Rows)
        {
            clsIndentItems objItems = new clsIndentItems();
            objItems.Op           = 1;
            objItems.IndentID     = IndentID;
            objItems.PartNo       = dr[2].ToString();
            objItems.Particular   = dr[3].ToString();
            objItems.CurrentStock = Convert.ToInt32(dr[4]);
            objItems.Quantity     = Convert.ToInt32(dr[5]);
            objItems.Remarks      = dr[6].ToString();
            objItems.IndentItemMaster(objItems);
        }
    }
    void LoadOrder()
    {
        clsIndent      obIndent      = new clsIndent();
        clsCustomer    obCustomer    = new clsCustomer();
        clsSite        obSite        = new clsSite();
        clsIndentItems obIndentItems = new clsIndentItems();
        clsUser        obU           = new clsUser();
        clsCompany     obC           = new clsCompany();
        DataTable      dtCustomer;

        //Company Detail
        obC.Op = 3;
        DataTable dtCompany = obC.CompanyMster(obC).Tables[0];

        //Indent detail
        obIndent.ID = Convert.ToInt32(Request.QueryString["ID"]);
        obIndent.Op = 4;
        DataTable dtIndent = obIndent.IndentMaster(obIndent).Tables[0];

        //User Detail
        obU.Op = 5;
        obU.ID = Convert.ToInt32(dtIndent.Rows[0]["Indentor"]);
        DataTable dtIndentor = obU.UserMaster(obU).Tables[0];

        obU.ID = Convert.ToInt32(dtIndent.Rows[0]["ApprovedBy"]);
        DataTable dtApprovedBy = obU.UserMaster(obU).Tables[0];

        //Customer Detail
        if (Convert.ToInt32(dtIndent.Rows[0]["OrderFrom"]) == 1)
        {
            //Site Detail
            obSite.Op  = 5;
            obSite.ID  = Convert.ToInt32(dtIndent.Rows[0]["OrderFromID"]);
            dtCustomer = obSite.SiteMaster(obSite).Tables[0];
        }
        else
        {
            //Customer Detail
            obCustomer.ID = Convert.ToInt32(dtIndent.Rows[0]["OrderFromID"]);
            obCustomer.Op = 4;
            dtCustomer    = obCustomer.CustomerMaster(obCustomer).Tables[0];
        }
        //Indent Items
        obIndentItems.IndentID = Convert.ToInt32(Request.QueryString["ID"]);
        obIndentItems.Op       = 2;
        DataTable      dtIndentItems = obIndentItems.IndentItemMaster(obIndentItems).Tables[0];
        LiteralControl lc            = new LiteralControl();

        lc.Text = "";
        lc.Text = lc.Text + "<div class='row'>";
        lc.Text = lc.Text + "<div class='col-lg-12'><center><h3>" + dtCompany.Rows[0]["Name"] + "</h3></center></div>";
        lc.Text = lc.Text + "<div class='col-lg-12'><center>Project Name: " + dtIndent.Rows[0]["ProjectNo"] + "</center></div>";
        lc.Text = lc.Text + "<div class='col-lg-12'><center>Job No: " + dtIndent.Rows[0]["JobNo"] + "</center></div>";
        lc.Text = lc.Text + "<div class='col-lg-12'><center><h3><u>INDENT FORM</u></h3></center></div>";
        lc.Text = lc.Text + "<div class='col-lg-9'>Ref No:" + dtIndent.Rows[0]["RefNo"] + "</div>";
        lc.Text = lc.Text + "<div class='col-lg-3'>Date:" + Convert.ToDateTime(dtIndent.Rows[0]["IndentDate"]).ToShortDateString() + "</div>";
        lc.Text = lc.Text + "<div class='col-lg-12' style='height:50px'></div>";

        lc.Text = lc.Text + "<div class='col-lg-12' style='height:500px'>";
        //Items//
        lc.Text = lc.Text + "<table width='100%' border='1' align='center'>";
        lc.Text = lc.Text + "<tr><td>Serial No</td><td>Part No</td><td>Particular Description</td><td>Current Stock</td><td>Quantity</td><td>Remarks</td></tr>";
        int i = 0;

        foreach (DataRow drItems in dtIndentItems.Rows)
        {
            i++;
            lc.Text = lc.Text + "<tr>";
            lc.Text = lc.Text + "<td>" + i.ToString() + "</td>";
            lc.Text = lc.Text + "<td>" + drItems["PartNo"] + "</td>";
            lc.Text = lc.Text + "<td>" + drItems["Particular"].ToString().Replace("\n", "<br>") + "</td>";
            lc.Text = lc.Text + "<td>" + drItems["CurrentStock"] + "</td>";
            lc.Text = lc.Text + "<td>" + drItems["Quantity"] + "</td>";
            lc.Text = lc.Text + "<td>" + drItems["Remarks"] + "</td>";
            lc.Text = lc.Text + "</tr>";
        }
        lc.Text = lc.Text + "</table>";

        //Items
        lc.Text = lc.Text + "</div>";

        lc.Text = lc.Text + "<div class='col-lg-12'>";
        lc.Text = lc.Text + "<table width='100%' border='1' align='center'>";
        lc.Text = lc.Text + "<tr height='100' align='center'><td>";


        lc.Text = lc.Text + "<img src='../" + dtIndentor.Rows[0]["Signature"] + "' height='50' width='120'/>";

        lc.Text = lc.Text + "<br>Indentor: " + dtIndentor.Rows[0]["Name"] + "</td>";
        lc.Text = lc.Text + "<td>";
        if (dtApprovedBy.Rows.Count > 0)
        {
            lc.Text = lc.Text + "<img src='../" + dtApprovedBy.Rows[0]["Signature"] + "' height='50' width='120'/>";

            lc.Text = lc.Text + "<br>Approved By: " + dtApprovedBy.Rows[0]["Name"];
        }
        lc.Text = lc.Text + "</td></tr></table>";
        lc.Text = lc.Text + "</div>";
        lc.Text = lc.Text + "</div>";
        Label lb = new Label();

        lb.Text = lc.ToString();
        pnlDetail.Controls.Add(lc);
        if (dtApprovedBy.Rows.Count == 0)
        {
            pnlApprove.Visible = true;
        }
        else
        {
            pnlApprove.Visible = false;
        }
    }
    void LoadOrderForPDF()
    {
        clsIndent      obIndent      = new clsIndent();
        clsCustomer    obCustomer    = new clsCustomer();
        clsSite        obSite        = new clsSite();
        clsIndentItems obIndentItems = new clsIndentItems();
        clsUser        obU           = new clsUser();
        clsCompany     obC           = new clsCompany();
        DataTable      dtCustomer;

        //Company Detail
        obC.Op = 3;
        DataTable dtCompany = obC.CompanyMster(obC).Tables[0];

        //Indent detail
        obIndent.ID = Convert.ToInt32(Request.QueryString["ID"]);
        obIndent.Op = 4;
        DataTable dtIndent = obIndent.IndentMaster(obIndent).Tables[0];

        //User Detail
        obU.Op = 5;
        obU.ID = Convert.ToInt32(dtIndent.Rows[0]["Indentor"]);
        DataTable dtIndentor = obU.UserMaster(obU).Tables[0];

        obU.ID = Convert.ToInt32(dtIndent.Rows[0]["ApprovedBy"]);
        DataTable dtApprovedBy = obU.UserMaster(obU).Tables[0];

        //Customer Detail
        if (Convert.ToInt32(dtIndent.Rows[0]["OrderFrom"]) == 1)
        {
            //Site Detail
            obSite.Op  = 5;
            obSite.ID  = Convert.ToInt32(dtIndent.Rows[0]["OrderFromID"]);
            dtCustomer = obSite.SiteMaster(obSite).Tables[0];
        }
        else
        {
            //Customer Detail
            obCustomer.ID = Convert.ToInt32(dtIndent.Rows[0]["OrderFromID"]);
            obCustomer.Op = 4;
            dtCustomer    = obCustomer.CustomerMaster(obCustomer).Tables[0];
        }
        //Indent Items
        obIndentItems.IndentID = Convert.ToInt32(Request.QueryString["ID"]);
        obIndentItems.Op       = 2;
        DataTable      dtIndentItems = obIndentItems.IndentItemMaster(obIndentItems).Tables[0];
        LiteralControl lc            = new LiteralControl();

        lc.Text = "";
        lc.Text = lc.Text + "<table width='100%'>";
        lc.Text = lc.Text + "<tr><td colspan='12' align='center'><h3>" + dtCompany.Rows[0]["Name"] + "</h3></td></tr>";
        lc.Text = lc.Text + "<tr><td colspan='12' align='center'>Project Name: " + dtIndent.Rows[0]["ProjectNo"] + "</h3></td></tr>";
        lc.Text = lc.Text + "<tr><td colspan='12' align='center'>Job No: " + dtIndent.Rows[0]["JobNo"] + "</h3></td></tr>";
        lc.Text = lc.Text + "<tr><td colspan='12' align='center'><h3><u>INDENT FORM</u></h3></td></tr>";
        lc.Text = lc.Text + "<tr><td colspan='9' align='left'>Ref No:" + dtIndent.Rows[0]["RefNo"] + "</td>";
        lc.Text = lc.Text + "<td colspan='3' align='right'>Date:" + Convert.ToDateTime(dtIndent.Rows[0]["IndentDate"]).ToShortDateString() + "</td></tr>";
        lc.Text = lc.Text + "<tr><td colspan='12' style='height:50'></td></tr>";

        lc.Text = lc.Text + "<tr><td colspan='12'>";
        //Items//
        lc.Text = lc.Text + "<table width='100%' border='1' align='center'>";
        lc.Text = lc.Text + "<tr><td colspan='1' align='center'>Serial No</td><td colspan='2' align='left'>Part No</td><td colspan='4' align='left'>Particular Description</td><td colspan='1' align='center'>Current Stock</td><td colspan='1' align='center'>Quantity</td><td colspan='3' align='left'>Remarks</td></tr>";
        int i = 0;

        foreach (DataRow drItems in dtIndentItems.Rows)
        {
            i++;
            lc.Text = lc.Text + "<tr>";
            lc.Text = lc.Text + "<td colspan='1' align='center'>" + i.ToString() + "</td>";
            lc.Text = lc.Text + "<td colspan='2' align='left'>" + drItems["PartNo"] + "</td>";
            lc.Text = lc.Text + "<td colspan='4' align='left'>" + drItems["Particular"].ToString().Replace("\n", "<br>") + "</td>";
            lc.Text = lc.Text + "<td colspan='1' align='center'>" + drItems["CurrentStock"] + "</td>";
            lc.Text = lc.Text + "<td colspan='1' align='center'>" + drItems["Quantity"] + "</td>";
            lc.Text = lc.Text + "<td colspan='3' align='left'>" + drItems["Remarks"] + "</td>";
            lc.Text = lc.Text + "</tr>";
        }
        if (i < 20)
        {
            i = 20 - i;
            while (i > 0)
            {
                lc.Text = lc.Text + "<tr border='0'><td colspan='12' border='0'><br></td></tr>";
                i--;
            }
        }
        lc.Text = lc.Text + "</table>";

        //Items
        lc.Text = lc.Text + "</td></tr>";

        lc.Text = lc.Text + "<tr><td colspan='12'>";
        lc.Text = lc.Text + "<table width='100%' border='1' align='center'>";
        lc.Text = lc.Text + "<tr height='100'><td align='center'>";

        try
        {
            if (dtIndentor.Rows[0]["Signature"].ToString().Trim() != "")
            {
                lc.Text = lc.Text + "<img src='" + MapPath("~/" + dtIndentor.Rows[0]["Signature"]) + "' height='50' width='120'/>";
            }

            lc.Text = lc.Text + "<br>Indentor: " + dtIndentor.Rows[0]["Name"] + "</td>";
        }
        catch
        {
        }
        lc.Text = lc.Text + "<td align='center'>";
        if (dtApprovedBy.Rows.Count > 0)
        {
            try
            {
                if (dtApprovedBy.Rows[0]["Signature"].ToString().Trim() != "")
                {
                    lc.Text = lc.Text + "<img src='" + MapPath("~/" + dtApprovedBy.Rows[0]["Signature"]) + "' height='50' width='120'/>";
                }
                lc.Text = lc.Text + "<br>Approved By: " + dtApprovedBy.Rows[0]["Name"];
            }
            catch
            {
            }
        }
        lc.Text = lc.Text + "</td></tr></table>";
        lc.Text = lc.Text + "</td></tr>";
        lc.Text = lc.Text + "</table>";
        Label lb = new Label();

        lb.Text = lc.ToString();
        pnlDetail.Controls.Add(lc);
    }