Пример #1
0
        public void ReturnCodingNo(BillType billType, string progId, DataRow masterRow, string codingNo)
        {
            CodingRule codingRule = LibCodingRuleCache.Default.GetCodingRule(billType, progId);
            int        serialLen  = 0;
            string     prefix     = GetPrefix(codingRule, masterRow, ref serialLen);

            LibCodingNoCache.Default.ReturnCodingNo(progId, prefix, codingNo);
        }
Пример #2
0
        private string GetPrefix(CodingRule codingRule, DataRow masterRow, ref int serialLen)
        {
            StringBuilder prefix = new StringBuilder();

            foreach (CodingRuleItem item in codingRule.Items)
            {
                switch (item.SectionType)
                {
                case SectionType.None:
                    prefix.Append(item.Value);
                    break;

                case SectionType.DateL:
                    prefix.Append(LibDateUtils.GetCurrentDate());
                    break;

                case SectionType.DateL1:
                    prefix.Append(LibDateUtils.GetCurrentDate().ToString().Remove(0, 2).Remove(4, 2));
                    break;

                case SectionType.DateS:
                    prefix.Append(LibDateUtils.GetCurrentDate().ToString().Remove(0, 2));
                    break;

                case SectionType.DateS1:
                    prefix.Append(LibDateUtils.GetSpecialDate());
                    break;

                case SectionType.DateAB:
                    prefix.Append(LibDateUtils.GetDateForABYear());
                    break;

                case SectionType.Dynamic:
                    if (masterRow != null)
                    {
                        string fieldValue = LibSysUtils.ToString(masterRow[item.FieldName]);
                        if (item.Values.ContainsKey(fieldValue))
                        {
                            prefix.Append(item.Values[fieldValue]);
                        }
                        else
                        {
                            string value = item.Values[item.FieldName];
                            //规则:如果没有设定字段为其他值时的固定字符。则默认使用字段当前值,不足用0补位
                            if (string.IsNullOrEmpty(value))
                            {
                                if (fieldValue.Length == item.Length)
                                {
                                    prefix.Append(fieldValue);
                                }
                                else if (fieldValue.Length > item.Length)
                                {
                                    prefix.Append(fieldValue.Substring(0, item.Length));
                                }
                                else
                                {
                                    prefix.Append(fieldValue.PadRight(item.Length, '0'));
                                }
                            }
                            else
                            {
                                prefix.Append(value);
                            }
                        }
                    }
                    break;

                case SectionType.SerialNum:
                    serialLen = item.Length;
                    break;

                default:
                    break;
                }
            }
            return(prefix.ToString());
        }
Пример #3
0
        public string GetCodingNo(BillType billType, string progId, string fieldName, DataRow masterRow, bool addNew, out CodingRule codingRule, LibDataAccess dataAccess)
        {
            string codingNo = string.Empty;

            codingRule = LibCodingRuleCache.Default.GetCodingRule(billType, progId);
            if ((!addNew && codingRule.CreateOnSave) || (addNew && !codingRule.CreateOnSave))
            {
                if (codingRule.Items.Count > 0)
                {
                    int    serialLen = 0;
                    string prefix    = GetPrefix(codingRule, masterRow, ref serialLen);
                    codingNo = LibCodingNoCache.Default.GetCodingNo(progId, fieldName, prefix, serialLen, dataAccess);
                }
            }
            return(codingNo);
        }