Example #1
0
    protected void ExcelPrintButton_Click(object sender, EventArgs e)
    {
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=Warehouse_InOut_" + System.DateTime.Today.ToString("yyyy-MM-dd") + ".xls");
        Response.Charset = "";

        // If you want the option to open the Excel file without saving then
        // comment out the line below
        // Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);
        GridViewSoSort.RenderControl(htmlWrite);
        GridViewWRSort.RenderControl(htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();
    }
Example #2
0
    protected void BindGridView()
    {
        try
        {
            if (ds.Tables["SortWRSQLTable"] == null)
            {
            }
            else if (ds.Tables["SortWRSQLTable"].Rows.Count == 0)
            {
                MakeEmptyGridView(GridViewWRSort, "SortWRSQLTable");
                MakeEmptyGridView(GridViewWRSortCustomer, "SortWRSQLTable");
                isEmptyIn = "Y";
            }
            else
            {
                GridViewWRSort.PageSize   = maxRows;
                GridViewWRSort.DataSource = ds.Tables["SortWRSQLTable"].DefaultView;
                GridViewWRSort.DataBind();
                GridViewWRSortCustomer.PageSize   = maxRows;
                GridViewWRSortCustomer.DataSource = ds.Tables["SortWRSQLTable"].DefaultView;
                GridViewWRSortCustomer.DataBind();
                isEmptyIn = null;
            }


            if (ds.Tables["IOEmptyTable"].Rows.Count == 0)
            {
                MakeEmptyGridView2(GridView2, "IOEmptyTable");
                GridView2.Visible = false;
            }
            else
            {
                GridView2.PageSize   = maxRows;
                GridView2.DataSource = ds.Tables["IOEmptyTable"].DefaultView;
                GridView2.DataBind();
            }

            if (ds.Tables["IOEmptyTable"].Rows.Count == 0)
            {
                MakeEmptyGridView2(GridView2, "IOEmptyTable");
                GridView3.Visible = false;
            }
            else
            {
                GridView3.PageSize   = maxRows;
                GridView3.DataSource = ds.Tables["IOEmptyTable"].DefaultView;
                GridView3.DataBind();
            }


            if (ds.Tables["SortSoSQLTable"] == null)
            {
            }
            else if (ds.Tables["SortSoSQLTable"] == null || ds.Tables["SortSoSQLTable"].Rows.Count == 0)
            {
                MakeEmptyGridView(GridViewSoSort, "SortSoSQLTable");
                MakeEmptyGridView(GridViewSoSortCustomer, "SortSoSQLTable");
                isEmptyIn = "Y";
            }
            else
            {
                GridViewSoSort.PageSize   = maxRows;
                GridViewSoSort.DataSource = ds.Tables["SortSoSQLTable"].DefaultView;
                GridViewSoSort.DataBind();
                GridViewSoSortCustomer.PageSize   = maxRows;
                GridViewSoSortCustomer.DataSource = ds.Tables["SortSoSQLTable"].DefaultView;
                GridViewSoSortCustomer.DataBind();
            }

            if (lstSortBy.SelectedIndex == 0)
            {
                GridViewSoSort.Visible         = false;
                GridView2.Visible              = false;
                GridViewSoSortCustomer.Visible = false;
                GridView3.Visible              = false;
                if (hAccountOfAcct.Value != "" && hAccountOfAcct.Value != "0")
                {
                    if (checkpart2() == true)
                    {
                        GridViewWRSort.Visible         = false;
                        GridViewWRSortCustomer.Visible = true;
                    }
                    else
                    {
                        GridViewWRSort.Visible         = true;
                        GridViewWRSortCustomer.Visible = false;
                    }
                }
                else
                {
                    GridViewWRSort.Visible         = true;
                    GridViewWRSortCustomer.Visible = false;
                }



                bindChildGridView("SortWRSQLTable", "InOutSQLTable", "GridViewWRDetail", GridViewWRSort, "WRRelation");
                bindChildGridView("SortWRSQLTable", "InOutSQLTable", "GridViewWRCustomerDetail", GridViewWRSortCustomer, "WRRelation");
            }
            else if (lstSortBy.SelectedIndex == 1)
            {
                if (hAccountOfAcct.Value != "" && hAccountOfAcct.Value != "0")
                {
                    if (checkpart2() == true)
                    {
                        GridViewSoSort.Visible         = false;
                        GridView2.Visible              = false;
                        GridViewSoSortCustomer.Visible = true;
                        GridView3.Visible              = true;
                    }
                    else
                    {
                        GridViewSoSort.Visible = true;
                        if (ds.Tables["IOEmptyTable"].Rows.Count != 0)
                        {
                            if (checkpart2a() == true)
                            {
                                GridView2.Visible = true;
                            }
                            else
                            {
                                GridView2.Visible = false;
                            }
                        }
                        else
                        {
                            GridView2.Visible = false;
                        }
                        GridViewSoSortCustomer.Visible = false;
                        GridView3.Visible = false;
                    }
                }
                else
                {
                    GridViewSoSort.Visible = true;
                    if (ds.Tables["IOEmptyTable"].Rows.Count != 0)
                    {
                        if (checkpart2a() == true)
                        {
                            GridView2.Visible = true;
                        }
                        else
                        {
                            GridView2.Visible = false;
                        }
                    }
                    GridViewSoSortCustomer.Visible = false;
                    GridView3.Visible = false;
                }

                if (GridView2.Rows[0].Cells[0].Text.ToString() == "None")
                {
                    GridView2.Visible = false;
                    GridView3.Visible = false;
                }

                else
                {
                    //if(GridViewSoSort.Rows[0].Cells[0].Text.ToString ==)
                }

                GridViewWRSort.Visible         = false;
                GridViewWRSortCustomer.Visible = false;
                bindChildGridView("SortSoSQLTable", "InOutSQLTable2", "GridViewSoDetail", GridViewSoSort, "SORelation");
                bindChildGridView("SortSoSQLTable", "InOutSQLTable2", "GridViewSoDetailCustomer", GridViewSoSortCustomer, "SORelation");
            }
            Get_total();
        }
        catch { }
    }