Exemple #1
0
        public static int GetSysParaFromIni(string sIniFileName)
        {
            string str = "";
            short  sI;

            sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Login", ref MyStart.gszSysLogin);
            if (sI < 0)
            {
                MyStart.gszSysLogin = "******";
            }
            sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Code", ref MyStart.gszSysCode);
            if (sI < 0)
            {
                MyStart.gszSysCode = "37601008";
            }

            sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Pwd", ref str);
            if (sI < 0)
            {
                MyStart.gszSysPwd = "1234567890";
            }
            else
            {
                if (str.Length == 16 && MyTools.StringIsHex(str))
                {
                    MyStart.gszSysPwd = MyTools.HideString_To_OpenString(str, MyIniFile.mszIniKey);
                    MyStart.gszSysPwd = MyStart.gszSysPwd.Trim();
                }
                else
                {
                    MyStart.gszSysPwd = "1234567890";
                }
            }

            // DB
            sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "IP", ref MyStart.gszDbIp);
            if (sI < 0)
            {
                MyStart.gszDbIp = "rm-wz9767aj327o0ai0ro.mysql.rds.aliyuncs.com";
            }
            //MyStart.gszDbIp = "183.58.24.209";//生产IP
            sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Port", ref MyStart.gszDbPort);
            if (sI < 0)
            {
                MyStart.gszDbPort = "3306";
            }
            //MyStart.gszDbPort = "8878";//生产端口
            sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref MyStart.gszDbSrv);
            if (sI < 0)
            {
                MyStart.gszDbSrv = "zsmkt";
            }
            sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Login", ref MyStart.gszDbLogin);
            if (sI < 0)
            {
                MyStart.gszDbLogin = "******";
            }

            /*sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Pwd", ref str);
             * if (sI < 0)
             * {
             *  MyStart.gszDbPwd = "Ztb_1324";// ThisSqlAly02&&";
             * }
             * else
             * {
             *  if (str.Length == 16 && MyTools.StringIsHex(str))
             *  {
             *      MyStart.gszDbPwd = MyTools.HideString_To_OpenString(str, MyIniFile.mszIniKey);
             *      MyStart.gszDbPwd = MyStart.gszDbPwd.Trim();
             *  }
             *  else
             *      MyStart.gszDbPwd = "Ztb_1324";//ThisSqlAly02&&";
             * }*/
            if (MyStart.gszDbIp == "139.159.212.93")
            {
                MyStart.gszDbPwd = "4077232";
            }
            else
            {
                MyStart.gszDbPwd = "Ztb_1324";
            }
            return(0);
        }
Exemple #2
0
        private void button_Login_Click(object sender, EventArgs e)
        {
            //String szYear = System.DateTime.Now.Year.ToString();
            //int iMonth = System.DateTime.Now.Month;
            //if (System.DateTime.Now > DateTime.Parse("2018.12.31"))
            //{
            //    MessageBox.Show("读程序参数错误,请检查!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return;
            //}

            DataSet ds    = new DataSet();
            string  szErr = "";
            string  szSql = "select user_pwd,user_id,USER_APP,USER_NAME,USER_STAT from sys_users where user_login='******'";// and USER_STAT='STOP'";
            int     iRst  = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);

            MyStart.oMyDb.Close();

            if (iRst != 0)
            {
                MessageBox.Show("连接数据库失败(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=" + szErr);
                return;
            }
            int iNum = ds.Tables[0].Rows.Count;

            if (iNum != 1)
            {
                MessageBox.Show("没有用户信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=没有用户信息");
                return;
            }

            DataRow dr = ds.Tables[0].Rows[0];

            if (dr[4].ToString().ToUpper() == "STOP")
            {
                MessageBox.Show("该帐号已停用,请重新登录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=该帐号已停用,请重新登录");
                textBox_Name.Focus();
                return;
            }

            string szPwd = MyTools.HideString_To_OpenString(dr[0].ToString(), MyStart.gszPwdKey);

            if (textBox_PW.Text.Trim() == szPwd.Trim())
            {
                MyStart.giUserID    = Convert.ToInt16(dr[1]);
                MyStart.gszUserPwd  = textBox_PW.Text.Trim();
                MyStart.gszUserApp  = dr[2].ToString();
                MyStart.gszUsername = dr[3].ToString();
                MyStart.UserCheckIn = true;

                string sIniFileName  = Application.StartupPath + "\\YTB.ini";
                int    sI            = 0;
                string sErrorMessage = "";
                MyStart.gszSysLogin = textBox_Name.Text;
                sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", MyStart.gszSysLogin);
                if (sI < 0)
                {
                    sErrorMessage = "保存 " + sIniFileName + "文件的操作员信息" + " 项时出错";
                    MessageBox.Show("操作错误:" + sErrorMessage + "。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("登录信息错误,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Name.Focus();
                return;
            }
        }