Exemple #1
0
        public string GetBillNo(string branchCode, int billType)
        {
            BillSetting billSetting = GetBillSetting(branchCode, billType);

            if (null == billSetting)
            {
                throw new ArgumentNullException(nameof(billSetting));
            }
            string      Num          = "";
            BILLFORMAT2 SerialFormat = SmartCrudHelper.GetEnumItemByValue <BILLFORMAT2>(billSetting.FSerialFormat);

            if (BILLFORMAT2.BIT36 == SerialFormat)
            {
                Num = AnyRadixConvert.ConvertTo(billSetting.FLstNumber, 36);
            }
            else if (BILLFORMAT2.BIT16 == SerialFormat)
            {
                Num = AnyRadixConvert.ConvertTo(billSetting.FLstNumber, 16);
            }
            else
            {
                Num = billSetting.FLstNumber.ToString();
            }
            if (!string.IsNullOrEmpty(billSetting.FFillChar))
            {
                int Fillbits = billSetting.FSerialbit - (billSetting.FLstSerialPreFix.Length + Num.Length);
                if (Fillbits > 0)
                {
                    Num = Num.PadLeft(Fillbits + Num.Length, billSetting.FFillChar[0]);
                }
            }
            return(string.Format("{0}{1}{2}", billSetting.FPrefix, billSetting.FLstSerialPreFix, Num));
        }
Exemple #2
0
        public BillSetting GetBillSetting(string branchCode, int billType)
        {
            BillSetting billSetting = _Conn.Select <BillSetting>(pkValues: new object[] { branchCode, billType }, tableName: BillTableName);

            if (null == billSetting)
            {
                return(null);
            }
            if (billSetting.FSerialFormat > 0)
            {
                string PrefixSerial = GetInitPrefixSerial(billSetting.FSerialFormat);
                if (string.Compare(billSetting.FLstSerialPreFix, PrefixSerial, true) != 0)
                {
                    if (string.IsNullOrWhiteSpace(billSetting.FLstSerialPreFix))//第一次使用,FLstSerialPreFix为空
                    {
                        _Conn.Update <BillSetting>(new BillSetting
                        {
                            FBillType        = billType,
                            FBranchCode      = branchCode,
                            FLstSerialPreFix = PrefixSerial
                        }, onlyFields: c => c.FLstSerialPreFix, tableName: BillTableName);
                    }
                    else
                    {
                        _Conn.ExecuteNonQuery($"Update {BillTableName} set FLstSerialPreFix=#LstPrefix#,FLstNumber=1 where FBranchCode=#BranchCode# and FBillType=#BillType#",
                                              new { LstPrefix = PrefixSerial, BranchCode = branchCode, BillType = billType });
                        billSetting.FLstSerialPreFix = PrefixSerial;
                        billSetting.FLstNumber       = 1;
                    }
                }
            }
            return(billSetting);
        }