Exemplo n.º 1
0
        /// <summary>
        /// 获得单据业务流配置下跟当前功能单据数据相匹配的业务流配置明细
        /// </summary>
        /// <param name="billMasterRow">功能单据 主表行数据</param>
        /// <param name="billProgId">功能单据 功能标识</param>
        /// <returns>返回业务流配置明细</returns>
        private List <BusinessInfo> GetBusinessInfo(DataRow billMasterRow, string billProgId)
        {
            //传输信息字典【使用条件--业务流配置明细】
            Dictionary <string, List <BusinessInfo> > businessInfoDic = new Dictionary <string, List <BusinessInfo> >();
            //单据业务流配置:axp.BusinessFlowConfig
            SqlBuilder sqlBuilder = new SqlBuilder(this.ProgId);
            //获取单据业务流配置下当前功能单据的业务流配置明细【使用条件,接收人代码,接收人名称,微信,发微信,电话,发短信】
            string sql = sqlBuilder.GetQuerySql(0, "B.USECONDITION,C.PERSONID,C.PERSONNAME,C.WECHAT,C.SENDWECHAT,C.PHONENO,C.NEEDSMS",
                                                string.Format("A.PROGID={0}", LibStringBuilder.GetQuotString(billProgId)), "B.USECONDITION");

            using (IDataReader reader = this.DataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    //单据业务流配置下当前功能单据 单据业务流配置规则配置 使用条件
                    string useCondition = LibSysUtils.ToString(reader["USECONDITION"]);
                    if (!businessInfoDic.ContainsKey(useCondition))
                    {
                        businessInfoDic.Add(useCondition, new List <BusinessInfo>());
                    }
                    BusinessInfo info = new BusinessInfo();
                    info.PersonId   = LibSysUtils.ToString(reader["PERSONID"]);
                    info.PersonName = LibSysUtils.ToString(reader["PERSONNAME"]);
                    info.WeChat     = LibSysUtils.ToString(reader["WECHAT"]);
                    info.SendWeChat = LibSysUtils.ToBoolean(reader["SENDWECHAT"]);
                    info.PhoneNo    = LibSysUtils.ToString(reader["PHONENO"]);
                    info.NeedSMS    = LibSysUtils.ToBoolean(reader["NEEDSMS"]);
                    businessInfoDic[useCondition].Add(info);
                }
            }
            //遍历字典找到使用条件跟当前功能单据数据相匹配的业务流配置明细
            List <BusinessInfo> curBusinessInfo = null;

            foreach (var item in businessInfoDic)
            {
                if (string.IsNullOrEmpty(item.Key))
                {
                    continue;
                }
                if (LibParseHelper.Parse(item.Key, new List <DataRow>()
                {
                    billMasterRow
                }))
                {
                    curBusinessInfo = item.Value;
                    break;
                }
            }
            //若未找到符合当前功能单据数据相匹配的业务流配置明细,则取默认的无条件的业务流配置明细
            if (curBusinessInfo == null && businessInfoDic.ContainsKey(string.Empty))
            {
                curBusinessInfo = businessInfoDic[string.Empty];
            }
            return(curBusinessInfo);
        }
Exemplo n.º 2
0
        public List <PrintTemplateIds> GetPrintTemplateIds(string billNo)
        {
            int                     num              = 0;
            string                  progId           = this.ProgId;
            string                  printTplId       = string.Empty;
            StringBuilder           builder          = new StringBuilder();
            SqlBuilder              sqlBuilder       = new SqlBuilder("axp.PrintTpl");
            SqlBuilder              sqlBillBuilder   = new SqlBuilder(this.ProgId);
            DataTable               dt               = new DataTable();
            List <PrintTemplateIds> printTemplateIds = new List <PrintTemplateIds>();

            builder.Append(sqlBuilder.GetQuerySql(0, "A.PRINTTPLID", string.Format("A.PROGID = {0}", LibStringBuilder.GetQuotString(progId))));
            using (IDataReader reader = this.DataAccess.ExecuteDataReader(builder.ToString()))
            {
                while (reader.Read())
                {
                    printTplId = LibSysUtils.ToString(reader["PRINTTPLID"]);
                }
            }
            if (printTplId == string.Empty)
            {
                this.ManagerMessage.AddMessage(LibMessageKind.Error, "打印模板尚未设置!");
            }
            else
            {
                builder.Clear();
                builder.Append(sqlBillBuilder.GetQuerySql(0, "A.*", string.Format("A.BILLNO = {0}", LibStringBuilder.GetQuotString(billNo))));
                this.DataAccess.ExecuteDataTable(builder.ToString(), dt);//将单据数据放入dt中
                builder.Clear();
                builder.Append(sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.USECONDITION", string.Format(" B.PRINTTPLID = {0} ", LibStringBuilder.GetQuotString(printTplId))));
                string sql = builder.ToString();
                using (IDataReader reader = this.DataAccess.ExecuteDataReader(builder.ToString(), true))
                {
                    while (reader.Read())
                    {
                        List <DataRow> dataRowList = new List <DataRow> {
                            dt.Rows[0]
                        };
                        if (LibSysUtils.ToString(reader["USECONDITION"]) != string.Empty)
                        {
                            if (LibParseHelper.Parse(LibSysUtils.ToString(reader["USECONDITION"]), dataRowList))//判断是否匹配到条件符合的打印模板明细
                            {
                                num = LibSysUtils.ToInt32(reader["ROW_ID"]);
                            }
                        }
                    }
                }
                if (num == 0)
                {
                    builder.Clear();
                    builder.Append(sqlBuilder.GetQuerySql(1, "B.ROW_ID", string.Format(" B.PRINTTPLID = {0} AND B.USECONDITION = '' ", LibStringBuilder.GetQuotString(printTplId))));
                    using (IDataReader reader = this.DataAccess.ExecuteDataReader(builder.ToString()))
                    {
                        while (reader.Read())
                        {
                            if (LibSysUtils.ToInt32(reader["ROW_ID"]) == 0)
                            {
                                this.ManagerMessage.AddMessage(LibMessageKind.Error, "打印模板明细中没有设置默认模板!");
                            }
                            else
                            {
                                num = LibSysUtils.ToInt32(reader["ROW_ID"]);
                            }
                        }
                    }
                }
                if (num > 0)
                {
                    builder.Clear();
                    builder.Append(sqlBuilder.GetQuerySql(2, "C.PRINTTPLID,C.PARENTROWID,C.ROW_ID", string.Format(" C.PRINTTPLID = {0} AND C.PARENTROWID = {1} ", LibStringBuilder.GetQuotString(printTplId), num), " C.ROW_ID ASC "));
                    using (IDataReader reader = this.DataAccess.ExecuteDataReader(builder.ToString(), true))
                    {
                        while (reader.Read())
                        {
                            PrintTemplateIds printTemplateId = new PrintTemplateIds();
                            printTemplateId.PrintTplNo       = LibSysUtils.ToString(reader["PRINTTPLID"]);
                            printTemplateId.PrintTplRowId    = LibSysUtils.ToInt32(reader["PARENTROWID"]);
                            printTemplateId.PrintTplSubRowId = LibSysUtils.ToInt32(reader["ROW_ID"]);
                            printTemplateIds.Add(printTemplateId);
                        }
                    }
                }
            }
            return(printTemplateIds);
        }