示例#1
0
        public static void InitAccount(string no, string param = "")
        {
            if (!DBHelper.DefaultInstance.Exist(string.Format("select 1 from master.sys.databases t where t.name='{0}'", no)))
            {
                throw new FinanceException(FinanceResult.RECORD_NOT_EXIST, string.Format("账套[{0}]不存在", no));
            }

            var idObj = DBHelper.DefaultInstance.ExecuteScalar(string.Format("select _id from _AccountCtl where _no='{0}'", no));

            if (idObj == null)
            {
                throw new FinanceException(FinanceResult.RECORD_NOT_EXIST, string.Format("账套[{0}]未加载", no));
            }

            if (param.Trim() == "-k")
            {
                var db = DBHelper.GetInstance(new Dictionary <string, object> {
                    { "Tid", (long)idObj }
                });
                db.ExecuteSql(@"delete from _VoucherEntryUdef; delete from _VoucherEntry; delete from _VoucherHeader;
delete from _TaskResult;delete from _OperationLog;delete from _SerialNo where _key > 0;
update _SystemProfile set _value = 0 where _category= 'Account' and _key = 'IsInited';");
            }
            else
            {
                SourceMain.Init((long)idObj);
            }
        }
示例#2
0
        public static void CreateAccount(string no, string name)
        {
            if (DBHelper.DefaultInstance.Exist(string.Format("select 1 from master.sys.databases t where t.name='{0}'", no)))
            {
                throw new FinanceException(FinanceResult.RECORD_EXIST, string.Format("账套[{0}]已存在", no));
            }
            CreateDB(no);
            if (DBHelper.DefaultInstance.Exist(string.Format("select 1 from _AccountCtl where _no='{0}'", no)))
            {
                DBHelper.DefaultInstance.ExecuteSql(string.Format("delete from _AccountCtl where _no='{0}'", no));
            }
            long id    = 1;
            var  maxId = DBHelper.DefaultInstance.ExecuteScalar("select max(_id) from _AccountCtl");

            if (maxId != null)
            {
                if (long.TryParse(maxId.ToString(), out id))
                {
                    id++;
                }
            }

            DataManager.GetInstance(null).Insert(new AccountCtl {
                connstr = BuildConnectString(no), id = id, no = no, name = name, createTime = DateTime.Now
            });
            SourceMain.Init(id);
        }
示例#3
0
        public static void InitData()
        {
            CreateDB("demo");

            var defaultConnectString = ConfigHelper.XmlReadConnectionString("Finance.exe.config", "default");

            var demoConnectString = BuildConnectString("demo");

            DataManager.GetInstance(null).Insert(new AccountCtl {
                connstr = demoConnectString, id = 0, no = "demo", name = "演示账套", createTime = DateTime.Now
            });
            DataManager.GetInstance(null).Insert(new AccountUser {
                id = 0, no = "admin", name = "管理员", pwd = "E10ADC3949BA59ABBE56E057F20F883E", lastLoginTime = DateTime.Now
            });

            SourceMain.Init(0);
        }