コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string zid = id.Text.Trim().ToString();
            //string weiTuoRen = weiTuoRen.SelectedValue.ToString();
            string tiDanHao1       = tiDanHao.Text.Trim().ToString();
            string xiangLiang1     = xiangLiang.Text.Trim().ToString();
            string zongZhongLiang1 = zongZhongLiang.Text.Trim().ToString();
            string daiBiaoXing1    = daiBiaoXing.Text.Trim().ToString();
            string pinMing1        = pinMing.Text.Trim().ToString();
            string state1          = state.SelectedValue.ToString();
            string url             = "Search.aspx?window=网页查询_客户委托情况_进口&se=";

            Session.RemoveAll();
            ISearchExpression se = null;

            if (!string.IsNullOrEmpty(zid))
            {
                se            = AndIfNecessary(se, SearchExpression.Like("货代自编号", "%" + zid + "%"));
                Session["id"] = zid;
            }
            if (!string.IsNullOrEmpty(tiDanHao1))
            {
                se = AndIfNecessary(se, SearchExpression.Like("提单号", "%" + tiDanHao1 + "%"));
                Session["tiDanHao"] = tiDanHao1;
            }
            if (!string.IsNullOrEmpty(xiangLiang1))
            {
                se = AndIfNecessary(se, SearchExpression.Eq("箱量", xiangLiang1));
                Session["xiangLiang"] = xiangLiang1;
            }
            if (!string.IsNullOrEmpty(zongZhongLiang1))
            {
                se = AndIfNecessary(se, SearchExpression.Eq("总重量", zongZhongLiang1));
                Session["zongZhongLiang"] = zongZhongLiang1;
            }
            if (!string.IsNullOrEmpty(daiBiaoXing1))
            {
                se = AndIfNecessary(se, SearchExpression.Like("代表性箱号", "%" + daiBiaoXing1 + "%"));
                Session["daiBiaoXing"] = daiBiaoXing1;
            }
            if (!string.IsNullOrEmpty(pinMing1))
            {
                se = AndIfNecessary(se, SearchExpression.Like("品名", "%" + pinMing1 + "%"));
                Session["pinMing"] = pinMing1;
            }
            if (!string.IsNullOrEmpty(state1))
            {
                se = AndIfNecessary(se, SearchExpression.Eq("当前状态", state1));
                //Session["state"] = state1;
            }
            if (!weiTuoTime1.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Ge("委托时间", weiTuoTime1.Value.Trim().ToString()));
            }
            if (!weiTuoTime2.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Le("委托时间", weiTuoTime2.Value.Trim().ToString()));
            }
            if (!daoGangTime1.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Ge("到港时间", daoGangTime1.Value.Trim().ToString()));
            }
            if (!daoGangTime2.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Le("到港时间", daoGangTime2.Value.Trim().ToString()));
            }
            if (!danZhengTime1.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Ge("单证齐全时间", danZhengTime1.Value.Trim().ToString()));
            }
            if (!danZhengTime2.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Le("单证齐全时间", danZhengTime2.Value.Trim().ToString()));
            }
            if (!jieGuanTime1.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Ge("结关时间", jieGuanTime1.Value.Trim().ToString()));
            }
            if (!jieGuanTime2.Value.Trim().ToString().Equals(""))
            {
                se = AndIfNecessary(se, SearchExpression.Le("结关时间", jieGuanTime2.Value.Trim().ToString()));
            }

            if (se != null)
            {
                //exp = HttpUtility.UrlEncode(exp);
                string exp = se.ToString();
                //exp = HttpUtility.UrlEncode(exp, System.Text.Encoding.GetEncoding("gb2312"));
                exp  = Server.UrlEncode(exp);
                url += exp;
            }
            Response.Redirect(url);
        }
コード例 #2
0
        /// <summary>
        /// 生成报表
        /// </summary>
        /// <param name="reportInfoName"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <returns></returns>
        public static byte[] GenerateReport(string reportInfoName, DateTime dateStart, DateTime dateEnd)
        {
            CrystalHelper crystalHelper = new CrystalHelper();

            ReportInfo reportInfo = ADInfoBll.Instance.GetReportInfo(reportInfoName);

            if (reportInfo == null)
            {
                throw new ArgumentException("不存在名为" + reportInfoName + "的ReportInfo!");
            }
            ReportDocument reportDocument = ReportHelper.CreateReportDocument(reportInfo.ReportDocument);

            crystalHelper.ReportSource = reportDocument;
            System.Data.DataSet templateDataSet = ReportHelper.CreateDataset(reportInfo.DatasetName);

            IList <ISearchManager> sms             = new List <ISearchManager>();
            IList <ReportDataInfo> reportDataInfos = ADInfoBll.Instance.GetReportDataInfo(reportInfo.Name);

            foreach (ReportDataInfo reportDataInfo in reportDataInfos)
            {
                if (string.IsNullOrEmpty(reportDataInfo.SearchManagerClassName))
                {
                    throw new ArgumentException("ReportDataInfo of " + reportDataInfo.Name + " 's SearchManagerClassName must not be null!");
                }

                ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(reportDataInfo.SearchManagerClassName, reportDataInfo.SearchManagerClassParams);

                sm.EnablePage = false;

                sms.Add(sm);
            }

            ISearchExpression se = SearchExpression.And(SearchExpression.Ge("日期", dateStart),
                                                        SearchExpression.Le("日期", dateEnd));

            for (int i = 0; i < reportDataInfos.Count; ++i)
            {
                System.Collections.IEnumerable dataList = sms[i].GetData(se, null);

                string s = reportDataInfos[i].DatasetTableName;
                if (!templateDataSet.Tables.Contains(s))
                {
                    throw new ArgumentException("报表DataSet中未包含名为" + s + "的DataTable!");
                }
                System.Data.DataTable dt = templateDataSet.Tables[s];
                dt.Rows.Clear();
                GenerateReportData.Generate(dt, dataList, reportDataInfos[i].GridName);
            }

            // Set Parameter
            SetParameter(crystalHelper, se);

            crystalHelper.DataSource = templateDataSet;

            string fileName = System.IO.Path.GetTempFileName();

            crystalHelper.Export(fileName, CrystalExportFormat.PortableDocFormat);

            System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] fileData         = new byte[fs.Length];

            using (System.IO.BinaryReader sr = new System.IO.BinaryReader(fs))
            {
                sr.Read(fileData, 0, fileData.Length);
            }
            fs.Close();
            System.IO.File.Delete(fileName);

            return(fileData);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchConditions"></param>
        /// <param name="searchOrders"></param>
        public virtual void FillSearchConditions(IList <ISearchExpression> searchConditions, IList <ISearchOrder> searchOrders)
        {
            if (Order.HasValue)
            {
                if (Order.Value)
                {
                    searchOrders.Add(SearchOrder.Asc(PropertyNameToSearch));
                }
                else
                {
                    searchOrders.Add(SearchOrder.Desc(PropertyNameToSearch));
                }
            }

            if (IsNull)
            {
                if (!IsNot)
                {
                    if (SearchNullUseFull)
                    {
                        searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch));
                    }
                    else
                    {
                        string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        searchConditions.Add(SearchExpression.IsNull(ss[0]));
                    }
                }
                else
                {
                    searchConditions.Add(SearchExpression.IsNotNull(PropertyNameToSearch));
                }
            }
            else
            {
                if (SelectedDataValue1 == null && SelectedDataValue2 == null)
                {
                    return;
                }

                if (SelectedDataValue1 != null && SelectedDataValue2 == null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                }
                else if (SelectedDataValue1 == null && SelectedDataValue2 != null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                }
                else
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.And(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1),
                                                                  SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Or(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1),
                                                                 SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.AdditionalSearchExpression))
            {
                searchConditions.Add(SearchExpression.Parse(this.AdditionalSearchExpression));
            }
        }
コード例 #4
0
        private ISearchExpression ParseSimpleExpression()
        {
            string            s1 = ParseWordExpression();
            string            s2;
            ISearchExpression exp;

            switch (this.token)
            {
            case TokenType.Eq:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Eq(s1, s2));

            case TokenType.NotEq:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.NotEq(s1, s2));

            case TokenType.EqProperty:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.EqProperty(s1, s2));

            case TokenType.Gt:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Gt(s1, s2));

            case TokenType.Ge:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Ge(s1, s2));

            case TokenType.Lt:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Lt(s1, s2));

            case TokenType.Le:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Le(s1, s2));

            case TokenType.InG:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.InG(s1, GetArrayList(s2)));

            case TokenType.GInG:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.GInG(s1, GetArrayList(s2)));

            case TokenType.Like:
                this.MoveNext();
                s2 = ParseWordExpression();
                return(SearchExpression.Like(s1, s2));

            case TokenType.IsNull:
                exp = SearchExpression.IsNull(s1);
                this.MoveNext();
                return(exp);

            case TokenType.IsNotNull:
                exp = SearchExpression.IsNotNull(s1);
                this.MoveNext();
                return(exp);

            case TokenType.Sql:
                exp = SearchExpression.Sql(s1);
                this.MoveNext();
                return(exp);

            default:
                throw new ArgumentException("Invalid token of " + token);
            }
        }