Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    string cargoCode     = Request.QueryString["cargoCode"].ToString().Trim();
                    string cargoName     = Request.QueryString["cargoName"].ToString().Trim();
                    string modelName     = Request.QueryString["modelName"].ToString().Trim();
                    string specName      = Request.QueryString["specName"].ToString().Trim();
                    string saleStatusStr = Request.QueryString["saleStatusStr"].ToString().Trim();
                    int    saleStatus    = -1;
                    if (!string.IsNullOrEmpty(saleStatusStr))
                    {
                        if (int.TryParse(saleStatusStr, out saleStatus) == false)
                        {
                            saleStatus = -1;
                        }
                    }

                    using (DAL.GoldEntities context = new DAL.GoldEntities())
                    {
                        List <DAL.proc_WebSelectEachDeptSaleAllocation_Result> resultList = context.proc_WebSelectEachDeptSaleAllocation().ToList <DAL.proc_WebSelectEachDeptSaleAllocation_Result>();


                        var queryResult = (from r in resultList
                                           where r.CargoCode.Contains(cargoCode) &&
                                           r.CargoName.Contains(cargoName) &&
                                           r.CargoModel.Contains(modelName) &&
                                           r.CargoSpec.Contains(specName) &&
                                           (saleStatus >= 0 ? r.SaleStatus == saleStatus : 1 == 1)
                                           select r).ToList();

                        Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", queryResult);
                        ReportViewer1.LocalReport.DataSources.Clear();
                        ReportViewer1.LocalReport.DataSources.Add(rds);

                        Microsoft.Reporting.WebForms.ReportParameter ReportParameter_CargoCode  = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter_CargoCode", cargoCode);
                        Microsoft.Reporting.WebForms.ReportParameter ReportParameter_CargoName  = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter_CargoName", cargoName);
                        Microsoft.Reporting.WebForms.ReportParameter ReportParameter_CargoModel = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter_CargoModel", modelName);
                        Microsoft.Reporting.WebForms.ReportParameter ReportParameter_CargoSpec  = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter_CargoSpec", specName);
                        Microsoft.Reporting.WebForms.ReportParameter ReportParameter_SaleStatus = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter_SaleStatus", saleStatus >= 0 ? (saleStatus > 0?"可售":"不可售"): "");

                        Microsoft.Reporting.WebForms.ReportParameterCollection rpList = new Microsoft.Reporting.WebForms.ReportParameterCollection();
                        rpList.Add(ReportParameter_CargoCode);
                        rpList.Add(ReportParameter_CargoName);
                        rpList.Add(ReportParameter_CargoModel);
                        rpList.Add(ReportParameter_CargoSpec);
                        rpList.Add(ReportParameter_SaleStatus);

                        ReportViewer1.LocalReport.SetParameters(rpList);
                        ReportViewer1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblGridViewMsg.Text = Utility.LogHelper.GetExceptionMsg(ex);
            }
        }
Ejemplo n.º 2
0
        void GridViewBind()
        {
            try
            {
                //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), "showWaitDiv('divWait');", true);//js提示

                //lblGridViewMsg.Text = "";

                string cargoCode     = tbxCargoCode.Text.Trim();
                string cargoName     = tbxCargoName.Text.Trim();
                string modelName     = DropDownList_CargoModel.SelectedItem.Text.Trim();
                string specName      = DropDownList_CargoSpec.SelectedItem.Text.Trim();
                string saleStatusStr = DropDownList_SaleStatus.SelectedItem.Value.Trim();
                int    saleStatus    = -1;
                if (!string.IsNullOrEmpty(saleStatusStr))
                {
                    if (int.TryParse(saleStatusStr, out saleStatus) == false)
                    {
                        saleStatus = -1;
                    }
                }

                using (DAL.GoldEntities context = new DAL.GoldEntities())
                {
                    List <DAL.proc_WebSelectEachDeptSaleAllocation_Result> resultList = context.proc_WebSelectEachDeptSaleAllocation().ToList <DAL.proc_WebSelectEachDeptSaleAllocation_Result>();


                    var queryResult = (from r in resultList
                                       where r.CargoCode.Contains(cargoCode) &&
                                       r.CargoName.Contains(cargoName) &&
                                       r.CargoModel.Contains(modelName) &&
                                       r.CargoSpec.Contains(specName) &&
                                       (saleStatus >= 0 ? r.SaleStatus == saleStatus : 1 == 1)
                                       select r).ToList();

                    string        sortExpression = gv_SaleAllocationList.Attributes["sortExpression"];
                    SortDirection sortDirection  = gv_SaleAllocationList.Attributes["sortDirection"] == "ASC" ? SortDirection.Ascending : SortDirection.Descending;

                    if (sortDirection == SortDirection.Ascending)
                    {
                        queryResult = queryResult.OrderBy(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }

                    //gv_SaleAllocationList.PageSize = WebConfigHelper.Instance.GetDefaultPageSize();//不分页
                    gv_SaleAllocationList.DataSource = queryResult;
                    gv_SaleAllocationList.DataBind();
                }
            }
            catch (Exception ex)
            {
                lblGridViewMsg.Text = "查询出现异常!" + Utility.LogHelper.GetExceptionMsg(ex);
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), "hiddenWaitDiv('divWait');", true);//js提示
            }
        }
Ejemplo n.º 3
0
        void GridViewBind()
        {
            try
            {
                //lblGridViewMsg.Text = "";

                string cargoCode = tbxCargoCode.Text.Trim();
                string cargoName = tbxCargoName.Text.Trim();
                string modelName = DropDownList_CargoModel.SelectedItem.Text.Trim();
                string specName  = DropDownList_CargoSpec.SelectedItem.Text.Trim();


                System.Diagnostics.Trace.WriteLine("proc start" + DateTime.Now.ToString("yy-MM-dd hh:mm:ss:ffff"));
                using (DAL.GoldEntities context = new DAL.GoldEntities())
                {
                    List <DAL.proc_WebSelectEachDeptSaleAllocation_Result> resultList = context.proc_WebSelectEachDeptSaleAllocation().ToList <DAL.proc_WebSelectEachDeptSaleAllocation_Result>();


                    var queryResult = (from r in resultList
                                       where r.CargoCode.Contains(cargoCode) &&
                                       r.CargoName.Contains(cargoName) &&
                                       r.CargoModel.Contains(modelName) &&
                                       r.CargoSpec.Contains(specName)
                                       select r).ToList();

                    string        sortExpression = gv_SaleAllocationList.Attributes["sortExpression"];
                    SortDirection sortDirection  = gv_SaleAllocationList.Attributes["sortDirection"] == "ASC" ? SortDirection.Ascending : SortDirection.Descending;

                    if (sortDirection == SortDirection.Ascending)
                    {
                        queryResult = queryResult.OrderBy(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }
                    else
                    {
                        queryResult = queryResult.OrderByDescending(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }

                    gv_SaleAllocationList.PageSize   = WebConfigHelper.Instance.GetDefaultPageSize();
                    gv_SaleAllocationList.DataSource = queryResult;
                    gv_SaleAllocationList.DataBind();
                }
                System.Diagnostics.Trace.WriteLine("proc end" + DateTime.Now.ToString("yy-MM-dd hh:mm:ss:ffff"));
#if entityframework
                string sortExpression = gv_SaleAllocationList.Attributes["sortExpression"];
                string sortDirection  = gv_SaleAllocationList.Attributes["sortDirection"];


                DataTable dtBind = SqlHelper.ExecuteDataTable("proc_WebSelectEachDeptSaleAllocation", System.Data.CommandType.StoredProcedure, null);
                // 根据GridView排序数据列及排序方向设置显示的默认数据视图
                if ((!string.IsNullOrEmpty(sortExpression)) && (!string.IsNullOrEmpty(sortDirection)))
                {
                    dtBind.DefaultView.Sort = string.Format("{0} {1}", sortExpression, sortDirection);
                }
                gv_SaleAllocationList.DataSource = dtBind.DefaultView.ToTable();
                gv_SaleAllocationList.DataBind();
#endif
            }
            catch (Exception ex)
            {
                lblGridViewMsg.Text = "查询出现异常!" + Utility.LogHelper.GetExceptionMsg(ex);
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), "hiddenWaitDiv('divWait');", true);//js提示
            }
        }