コード例 #1
0
ファイル: DbRollbackRecord.cs プロジェクト: Lierba2014/erp-2
        public bool databaseRollback(string dbFile)
        {
            // RESTORE DATABASE [ERP] FROM  DISK = N'xxxxxxxxxxx' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10
            string sql = "RESTORE DATABASE [ERP] FROM  DISK = N\'";

            sql += dbFile;
            sql += "\' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10";

            try
            {
                DatabaseAccessFactoryInstance.Instance.ExecuteCommand(FormMain.DB_NAME_MASTER, "ALTER DATABASE [ERP] SET SINGLE_USER WITH ROLLBACK IMMEDIATE");
                DatabaseAccessFactoryInstance.Instance.ExecuteCommand(FormMain.DB_NAME_MASTER, sql);

                MessageBoxExtend.messageOK("数据库恢复成功! 需要重启ERP系统");

                CurrentLoginUser.getInctance().delete();
                Process.Start(@"MainProgram.exe");
                Process.GetCurrentProcess().Kill();
            }
            catch (Exception error)
            {
                MessageBoxExtend.messageWarning(error.Message);
                return(false);
            }

            return(true);
        }
コード例 #2
0
        static public CurrentLoginUser getInctance()
        {
            if (m_instance == null)
            {
                m_instance = new CurrentLoginUser();
            }

            return(m_instance);
        }
コード例 #3
0
 public bool isOnline(int pkey)
 {
     return(CurrentLoginUser.getInctance().userIsOnline(pkey));
 }
コード例 #4
0
ファイル: BillNumber.cs プロジェクト: Lierba2014/erp-2
        public string getNewBillNumber(int billTypeNumber, string date)
        {
            string newBillNumber = "";

            if (billTypeNumber < 10)
            {
                newBillNumber += "0";
            }

            newBillNumber += Convert.ToString(billTypeNumber) + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");

            if (checkIsQuit())
            {
                MessageBoxExtend.messageWarning("系统目前为非注册(正版)软件,单据现已超过200张,无法再继续使用。\n请联系软件供应商,索取正版序列号。");
                CurrentLoginUser.getInctance().delete();

                Process.GetCurrentProcess().Kill();
            }
            //else
            //{
            //    try
            //    {
            //        // 查询BASE_BILL_CONFIG表,根据单据类型得到单据的前缀

            //        string front = "";
            //        int isUsrRules = 0, isUseSysdate = 0, num = 0;

            //        string query = "SELECT FRONT, IS_USE_RULES, IS_USE_SYSDATE, NUM FROM BASE_BILL_CONFIG WHERE BILL_TYPE = " + billTypeNumber;

            //        using (DataTable dataTable1 = DatabaseAccessFactoryInstance.Instance.QueryDataTable(FormMain.DB_NAME, query))
            //        {
            //            if (dataTable1.Rows.Count > 0)
            //            {
            //                front = DbDataConvert.ToString(dataTable1.Rows[0][0]);
            //                isUsrRules = DbDataConvert.ToInt32(dataTable1.Rows[0][1]);
            //                isUseSysdate = DbDataConvert.ToInt32(dataTable1.Rows[0][2]);
            //                num = DbDataConvert.ToInt32(dataTable1.Rows[0][3]);

            //                if (isUsrRules == 1)
            //                {
            //                    newBillNumber = front;

            //                    string sNewBillNumber = Convert.ToString(getMaxBillNumber(billTypeNumber, date));

            //                    if (isUseSysdate == 1)
            //                    {
            //                        newBillNumber += "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
            //                    }
            //                    else
            //                    {
            //                        newBillNumber += "-" + DateTime.Now.ToString("ddssfff") + DateTime.Now.ToString("ddssfff");
            //                    }

            //                    //newBillNumber += "-";

            //                    //for (int i = 0; i < num - sNewBillNumber.Length; i++)
            //                    //{
            //                    //    newBillNumber += "0";
            //                    //}

            //                    //newBillNumber += sNewBillNumber;
            //                }
            //            }
            //        }

            //    }
            //    catch (Exception)
            //    {

            //    }
            //}

            return(newBillNumber);
        }