コード例 #1
0
ファイル: CAppOption.cs プロジェクト: xyt2008/Restaurant
        /// <summary>
        /// 保存数据
        /// </summary>
        public static void SaveData()
        {
            string szOptionFile;

            szOptionFile = System.Windows.Forms.Application.StartupPath + "\\Option.dat";


            int iRet = 0;

            iRet = PlatformInvokeKernel32.WritePrivateProfileString("App", "AppStyle", iAppStyle.ToString(), szOptionFile);
            iRet = PlatformInvokeKernel32.WritePrivateProfileString("App", "Idiograph", Idiograph, szOptionFile);


            iRet = PlatformInvokeKernel32.WritePrivateProfileString("Windows", "Style", iFormStyle.ToString(), szOptionFile);
            iRet = PlatformInvokeKernel32.WritePrivateProfileString("Windows", "SortStyle", iSortStyle.ToString(), szOptionFile);
            iRet = PlatformInvokeKernel32.WritePrivateProfileString("Windows", "NumberFormat", NumberFormat, szOptionFile);
            iRet = PlatformInvokeKernel32.WritePrivateProfileString("Windows", "MoneyFormat", MoneyFormat, szOptionFile);
            iRet = PlatformInvokeKernel32.WritePrivateProfileString("Windows", "PageRowCount", PageRowCount.ToString(), szOptionFile);

            WindowStyleMan.SaveData();

            RegistryKey oRegSoft;

            oRegSoft = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
            if (oRegSoft == null)
            {
                //建立
                oRegSoft = Registry.LocalMachine.CreateSubKey("SOFTWARE");
            }

            RegistryKey oRegTemp = oRegSoft.OpenSubKey(Application.ProductName, true);

            if (oRegTemp == null)
            {
                oRegTemp = oRegSoft.CreateSubKey(Application.ProductName);
            }
#if RELEASE || DEBUG
            oRegTemp.SetValue("DbConnect", CYyScrypt.Encrypt(m_sDbConnectString));
#endif

            oRegTemp.SetValue("User", m_sUser);
            oRegTemp.SetValue("Pwd", CYyScrypt.Encrypt(m_sPwd));
            oRegTemp.SetValue("SavePwd", m_bSavePwd);
            oRegTemp.Flush();
        }
コード例 #2
0
ファイル: UserDbAdaHelper.cs プロジェクト: xyt2008/Restaurant
        public bool LoginPwdInit(long PersonnelID)
        {
            string Pwd = "123456";

            Pwd = CYyScrypt.Encrypt(Pwd);
            List <OleDbParameter> Param = new List <OleDbParameter>();

            Param.Add(Db.MakeInParam("Pwd", System.Data.OleDb.OleDbType.VarChar, 256, Pwd));
            Param.Add(Db.MakeInParam("PersonID", System.Data.OleDb.OleDbType.BigInt, 8, PersonnelID));

            if (Db.ExecSql("Update tLogin Set Pwd=? where PersonID =?;", Param) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        private void toolStripButtonMod_Click(object sender, EventArgs e)
        {
            if (dgvUserLogin.CurrentRow != null)
            {
                int IsLogin = Convert.ToInt32(dgvUserLogin.CurrentRow.Cells["ColumnIsLogin"].Value);
                if (IsLogin == 1)
                {
                    MessageBox.Show("该职员已经有登录权限!");
                    return;
                }
                long PersonnelID = Convert.ToInt64(dgvUserLogin.CurrentRow.Cells["ColumnPersonnelID"].Value);

                FormUser dlg = new FormUser();

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    m_DbAdaHelper.AddLogin(PersonnelID, dlg.User, CYyScrypt.Encrypt(dlg.Pwd));

                    dgvUserLogin.DataSource = m_DbAdaHelper.GetUserLogin();
                }
            }
        }
コード例 #4
0
ファイル: CAppOption.cs プロジェクト: zanderzhg/Restaurant-1
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void LoadData()
        {
            string szOptionFile;

            szOptionFile = System.Windows.Forms.Application.StartupPath + "\\Option.dat";
            if (System.IO.File.Exists(szOptionFile))
            {
                System.Text.StringBuilder szValue = new System.Text.StringBuilder("", 256);

                int iRet;
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("App", "AppStyle", iAppStyle.ToString(), szValue, 256, szOptionFile);
                try
                {
                    iAppStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "Style", iFormStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iFormStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "SortStyle", iSortStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iSortStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "NumberFormat", NumberFormat, szValue, 256, szOptionFile);

                NumberFormat = szValue.ToString();
                if (NumberFormat == "")
                {
                    NumberFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "MoneyFormat", MoneyFormat, szValue, 256, szOptionFile);

                MoneyFormat = szValue.ToString();
                if (MoneyFormat == "")
                {
                    MoneyFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "PageRowCount", PageRowCount.ToString(), szValue, 256, szOptionFile);

                try
                {
                    PageRowCount = Convert.ToInt32(szValue.ToString());
                    if (PageRowCount < 10)
                    {
                        PageRowCount = 22;
                    }
                }
                catch
                {
                    PageRowCount = 22;
                }

                iRet      = PlatformInvokeKernel32.GetPrivateProfileString("App", "Idiograph", "", szValue, 256, szOptionFile);
                Idiograph = szValue.ToString();

                //注册码
                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "Code", "", szValue, 256, szOptionFile);
                RegisterCode = szValue.ToString();

                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "User", "", szValue, 256, szOptionFile);
                RegisterUser = szValue.ToString();

                string[] MacList = CGeneralFunction.GetMac();
                ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("Mac:{0}", MacList[0]));

                if (MacList.Length > 0)
                {
                    SimpleScrypt SScrypt = new SimpleScrypt();
                    if (SScrypt.Encrypt(MacList[0]) == RegisterCode)
                    {
                        bRegister = true;
                    }
                    if (!string.IsNullOrEmpty(RegisterUser) && SScrypt.Encrypt(RegisterUser) == RegisterCode)
                    {
                        bRegister = true;
                    }
#if DEBUG
                    if (bRegister == false)
                    {
                        ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(MacList[0])));
                        ChefMonitor.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(RegisterUser)));
                    }
#endif
                }
            }
            WindowStyleMan.LoadData();


            RegistryKey oRegSoft;
            oRegSoft = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
            if (oRegSoft == null)
            {
                //建立
                oRegSoft = Registry.LocalMachine.CreateSubKey("SOFTWARE");
            }

            RegistryKey oRegTemp = oRegSoft.OpenSubKey(Application.ProductName, true);
            if (oRegTemp == null)
            {
                oRegTemp = oRegSoft.CreateSubKey(Application.ProductName);
            }
            m_sUser = (string)oRegTemp.GetValue("User", "Admin");

            m_sPwd = ""; //20090110修改,不再
                         //m_sPwd=Decrypt((string)oRegTemp.GetValue("Pwd",""));

            m_sDbConnectString = CYyScrypt.Decrypt((string)oRegTemp.GetValue("DbConnect", CYyScrypt.Encrypt(m_sDbConnectString)));
            m_bSavePwd         = Convert.ToBoolean(oRegTemp.GetValue("SavePwd", true));
        }
コード例 #5
0
ファイル: CAppOption.cs プロジェクト: xyt2008/Restaurant
        /// <summary>
        /// 加载数据
        /// </summary>
        public static void LoadData()
        {
            string szOptionFile;

            szOptionFile = System.Windows.Forms.Application.StartupPath + "\\Option.dat";
            if (System.IO.File.Exists(szOptionFile))
            {
                System.Text.StringBuilder szValue = new System.Text.StringBuilder("", 256);

                int iRet;
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("App", "AppStyle", iAppStyle.ToString(), szValue, 256, szOptionFile);
                try
                {
                    iAppStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "Style", iFormStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iFormStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "SortStyle", iSortStyle.ToString(), szValue, 256, szOptionFile);

                try
                {
                    iSortStyle = Convert.ToInt32(szValue.ToString());
                }
                catch
                {
                }
                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "NumberFormat", NumberFormat, szValue, 256, szOptionFile);

                NumberFormat = szValue.ToString();
                if (NumberFormat == "")
                {
                    NumberFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "MoneyFormat", MoneyFormat, szValue, 256, szOptionFile);

                MoneyFormat = szValue.ToString();
                if (MoneyFormat == "")
                {
                    MoneyFormat = "0.00";
                }

                iRet = PlatformInvokeKernel32.GetPrivateProfileString("Windows", "PageRowCount", PageRowCount.ToString(), szValue, 256, szOptionFile);

                try
                {
                    PageRowCount = Convert.ToInt32(szValue.ToString());
                    if (PageRowCount < 10)
                    {
                        PageRowCount = 22;
                    }
                }
                catch
                {
                    PageRowCount = 22;
                }

                iRet      = PlatformInvokeKernel32.GetPrivateProfileString("App", "Idiograph", "", szValue, 256, szOptionFile);
                Idiograph = szValue.ToString();

                //注册码
                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "Code", "", szValue, 256, szOptionFile);
                RegisterCode = szValue.ToString();

                iRet         = PlatformInvokeKernel32.GetPrivateProfileString("Register", "User", "", szValue, 256, szOptionFile);
                RegisterUser = szValue.ToString();

                string strMac = CGeneralFunction.GetMACaddressOne();
                Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("Mac:{0}", strMac));

                if (strMac.Length > 0)
                {
                    SimpleScrypt SScrypt = new SimpleScrypt();
                    if (SScrypt.Encrypt(strMac) == RegisterCode)
                    {
                        bRegister = true;
                    }
                    if (!string.IsNullOrEmpty(RegisterUser) && SScrypt.Encrypt(RegisterUser) == RegisterCode)
                    {
                        bRegister = true;
                    }
#if DEBUG
                    if (bRegister == false)
                    {
                        Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(strMac)));
                        Restaurant.CGlobalInstance.Instance.FileLogger.WriteLog(YyLogger.LogSeverity.info, "配置加载", string.Format("RegisterCode:{0}", SScrypt.Encrypt(RegisterUser)));
                    }
#endif
                }
            }
            WindowStyleMan.LoadData();


            RegistryKey oRegSoft;
            oRegSoft = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
            if (oRegSoft == null)
            {
                //建立
                oRegSoft = Registry.LocalMachine.CreateSubKey("SOFTWARE");
            }

            RegistryKey oRegTemp = oRegSoft.OpenSubKey(Application.ProductName, true);
            if (oRegTemp == null)
            {
                oRegTemp = oRegSoft.CreateSubKey(Application.ProductName);
            }
            m_sUser = (string)oRegTemp.GetValue("User", "Admin");

            m_sPwd = ""; //20090110修改,不再
                         //m_sPwd=Decrypt((string)oRegTemp.GetValue("Pwd",""));

            //Jet的开发已经停止了,所以没有64位的版本。
            //Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\DB\Restaurant.mdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123
            //Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\DB\Restaurant.accdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123
            string strAcc = "";//CYyScrypt.Encrypt(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Restaurant.mdb;Persist Security Info=False;Jet OLEDB:DataBase Password=legahero123");
            strAcc = "501D3F1847F9C54142AA6F0AF66D6F44C616C01EE400418CDAC8F89571A22E17D16E33A09E861EB9B253E258914D771FFDFDD75238B3085A49A885C62DFDF07D28F5DB62128B2D2D56D99B6571A27D9997C8EC446A5486366356281FBA2054D696DB7FA70E84BE91652FD7E333AA30A4DCEF7FE9D96538F2A43E3AA1777167209D4FE216F3A74373F152199CF089A987E707D7313E695522A798E4F5CAB316C1D1F72C51761BA18CA5BA726083D45D667DCA404A0CB8A5152BDCC50131A32A2BF554FCFF4FCE7AD9CC98DD954F54B177ED27D8D45E46078D704C8A83E3C4F0A8ED4E069B18936EB1998A7C72599628214665452AE7F5E217D98DD2674884";

#if TMPRELEASE
            //单机版
            m_sDbConnectString = CYyScrypt.Decrypt(strAcc);
#else
            m_sDbConnectString = CYyScrypt.Decrypt((string)oRegTemp.GetValue("DbConnect", CYyScrypt.Encrypt(m_sDbConnectString)));
#endif
            m_bSavePwd = Convert.ToBoolean(oRegTemp.GetValue("SavePwd", true));
        }