예제 #1
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (textBox_Old_Pwd.Text.Trim().ToUpper().CompareTo(MyStart.gszUserPwd.ToUpper()) != 0)
            {
                MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_Old_Pwd.Focus();
                return;
            }

            if (textBox_New_Pwd.Text.CompareTo(textBox_2nd_Pwd.Text) != 0)
            {
                MessageBox.Show("两次输入的新密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox_New_Pwd.Focus();
                return;
            }

            string szNewPwd = MyTools.OpenString_To_HideString((textBox_New_Pwd.Text + "        ").Substring(0, 8),
                                                               MyStart.gszPwdKey);
            string szSql = "UPDATE sys_users SET USER_PWD = '" + szNewPwd
                           + "' WHERE USER_ID=" + MyStart.giUserID;
            string szErr = "";

            try
            {
                int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("更改密码失败(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog("当班人员-更改密码", "SQL=" + szSql + ",Err=" + szErr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("更改密码失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            MyStart.oMyDb.Close();

            MyFunc.WriteToDbLog("当班人员-更改密码", "", "MSG", MyStart.giUserID);
            MessageBox.Show("更改密码成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #2
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            string sIniFileName  = Application.StartupPath + "\\YTB.ini";
            int    sI            = 0;
            string sErrorMessage = "";
            string sTmp;

            /*
             * if (textBox_Pwd1.Text.Trim() != textBox_Pwd2.Text.Trim())
             * {
             *  sI = -1;
             *  sErrorMessage = "两次输入的系统登录密码不相等,请更正";
             *  goto Eend;
             * }
             * if (textBox_Pwd1.Text.Length > 8)
             * {
             *  sI = -1;
             *  sErrorMessage = "系统登录密码长度不能超过8个字节,请更正";
             *  goto Eend;
             * }
             * //if (textBox_SrvUserPass.Text.Length > 8)
             * //{
             * //    sI = -1;
             * //    sErrorMessage = "数据库密码长度不能超过8个字节,请更正";
             * //    goto Eend;
             * //}
             */
            sI = -1;
            MyStart.gszDbIp    = textBox_SrvIP.Text.Trim();
            MyStart.gszDbPort  = textBox_SrvPort.Text.Trim();
            MyStart.gszDbLogin = textBox_SrvUserName.Text.Trim();
            MyStart.gszDbPwd   = textBox_SrvUserPass.Text;
            MyStart.gszDbSrv   = textBox_SrvDataBase.Text.Trim();

            MyStart.gszYTBIp   = textBox_YTB_IP.Text;
            MyStart.gszYTBPort = textBox_YTB_PORT.Text;

            MyStart.gszRdrPort  = comboBox_Rdr_Comm.Text.Substring(4);
            MyStart.gszRdr2Port = comboBox_Rdr2_Comm.Text.Substring(4);
            MyStart.gszRdrBaud  = comboBox_Rdr_Baud.Text;

            MyStart.gszPsPort = comboBox_PS_Comm.Text.Substring(4);
            MyStart.gszPsBaud = comboBox_PS_Baud.Text;

            /*sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", MyStart.szSysLogin);
             * if (sI < 0)
             * {
             *  sErrorMessage = "保存 " + sIniFileName + "文件的 Sys.Login" + " 项时出错";
             *  goto Eend;
             * }
             *
             * sTmp = MyTools.OpenString_To_HideString((textBox_Pwd1.Text + "        ").Substring(0, 8));
             * sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Pwd", sTmp);
             * if (sI < 0)
             * {
             *  sErrorMessage = "保存 " + sIniFileName + "文件的 Sys.Pwd" + " 项时出错";
             *  goto Eend;
             * }*/

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "IP", MyStart.gszDbIp);
            if (sI < 0)
            {
                sErrorMessage = "保存 " + sIniFileName + "文件的 Db.IP" + " 项时出错";
                goto Eend;
            }
            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Port", MyStart.gszDbPort);
            if (sI < 0)
            {
                sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Port" + " 项时出错";
                goto Eend;
            }
            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Srv", MyStart.gszDbSrv);
            if (sI < 0)
            {
                sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Srv" + " 项时出错";
                goto Eend;
            }
            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Login", MyStart.gszDbLogin);
            if (sI < 0)
            {
                sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Login" + " 项时出错";
                goto Eend;
            }
            if (textBox_SrvUserPass.Text.Length <= 8)
            {
                sTmp = MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text + "        ").Substring(0, 8), MyIniFile.mszIniKey);
            }
            else
            {
                sTmp  = MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text.Substring(0, 8)), MyIniFile.mszIniKey);
                sTmp += MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text.Substring(8) + "        ").Substring(0, 8), MyIniFile.mszIniKey);
            }
            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Pwd", sTmp);
            if (sI < 0)
            {
                sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Pwd" + " 项时出错";
                goto Eend;
            }

            string szErr = "";

            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "YTB_SRV", MyStart.gszYTBIp, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存益通宝平台.IP" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "YTB_PORT", MyStart.gszYTBPort, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存益通宝平台.端口" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR_PORT", MyStart.gszRdrPort, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存读卡器.连接端口" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR2_PORT", MyStart.gszRdr2Port, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存后台用读卡器.连接端口" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR_BAUD", MyStart.gszRdrBaud, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存读卡器.连接波特率" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "PS_PORT", MyStart.gszPsPort, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存磅秤.连接端口" + " 项时出错";
                goto Eend;
            }
            sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "PS_BAUD", MyStart.gszPsBaud, ref szErr);
            if (sI < 0)
            {
                sErrorMessage = "保存磅秤.连接波特率" + " 项时出错";
                goto Eend;
            }

Eend:
            //string sUserTZM = MyTools.sGetMachineTZM();
            //if (MyStart.sUserAuthCode == MyTools.sGetAuthCode(sUserTZM))
            //    MyStart.bAuthCodeIsOK = true;
            //else
            //    MyStart.bAuthCodeIsOK = false;
            button_Edit.Enabled = true;
            button_Save.Enabled = false;
            button_Quit.Enabled = false;
            button_Exit.Enabled = true;

            groupBox_YTB.Enabled = false;
            groupBox_RDR.Enabled = false;
            groupBox_PS.Enabled  = false;
            groupBox_Db.Enabled  = false;
            if (sI < 0)
            {
                MessageBox.Show("操作错误:" + sErrorMessage + "。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MyFunc.WriteToDbLog("修改系统参数", "", "MSG", MyStart.giUserID);
                //MessageBox.Show("Ini文件保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            button_Exit.Select();
            MyStart.oMyDb.Close();
        }
예제 #3
0
        /*
         * public static void GetIni(ref string szSysLogin, ref string szSysPwd,
         *  ref string szDbIp, ref string szDbPort, ref string szDbSrv,
         *  ref string szDbLogin, ref string szDbPwd)
         * {
         *  string str = "";
         *  short sI;
         *  string sIniFileName = Application.StartupPath + mszIniFile;
         *
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Login", ref szSysLogin);
         *  if (sI < 0) szSysLogin = "******";
         *
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Pwd", ref str);
         *  if (sI < 0)
         *  {
         *      szSysPwd = "1234567890";
         *  }
         *  else
         *  {
         *      if (str.Length == 16 && MyTools.StringIsHex(str))
         *      {
         *          szSysPwd = MyTools.HideString_To_OpenString(str, mszIniKey);
         *          szSysPwd = szSysPwd.Trim();
         *      }
         *      else
         *          szSysPwd = "1234567890";
         *  }
         *
         *  // DB
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "IP", ref szDbIp);
         *  if (sI < 0) szDbIp = "rm-bp15ol05h0es8f5eco.mysql.rds.aliyuncs.com";
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Port", ref szDbPort);
         *  if (sI < 0) szDbPort = "3306";
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref szDbSrv);
         *  if (sI < 0) szDbSrv = "zsmkt";
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref szDbLogin);
         *  if (sI < 0) szDbLogin = "******";
         *  sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Pwd", ref str);
         *  if (sI < 0)
         *  {
         *      szDbPwd = "Ztb_1324";
         *  }
         *  else
         *  {
         *      if (str.Length == 16 && MyTools.StringIsHex(str))
         *      {
         *          szDbPwd = MyTools.HideString_To_OpenString(str, mszIniKey);
         *          szDbPwd = szDbPwd.Trim();
         *      }
         *      else
         *          szDbPwd = "Ztb_1324";
         *  }
         * }*/

        public static bool SetIni(string SysLogin_New, string SysPwd_New, string KM_IP_New, string KM_PORT_New, string DB_Addr_New, int iSamRd_New, int iRFRd_New)
        {
            string str = "";
            short  sI;
            string sIniFileName = Application.StartupPath + "\\SYS.ini";

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", SysLogin_New);
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 Sys.Login 项时出错";
                goto Eend;
            }

            str = MyTools.OpenString_To_HideString((SysPwd_New + "        ").Substring(0, 8), mszIniKey);
            sI  = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Pwd", str);
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + "文件的 Sys.Pwd 项时出错";
                goto Eend;
            }

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "KM", "IP", KM_IP_New);
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 KM.IP 项时出错";
                goto Eend;
            }

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "KM", "Port", KM_PORT_New);
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 KM.Port 项时出错";
                goto Eend;
            }

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "DbSrv", "Addr", DB_Addr_New);
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 DbSrv.Addr 项时出错";
                goto Eend;
            }

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Comm", "SAM_DEV", iSamRd_New.ToString());
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 Comm.SAM_DEV 项时出错";
                goto Eend;
            }

            sI = MyIniFile.SetIniKeyValue(sIniFileName, "Comm", "RF_DEV", iRFRd_New.ToString());
            if (sI < 0)
            {
                str = "保存 " + sIniFileName + " 文件的 Comm.RF_DEV 项时出错";
                goto Eend;
            }
            return(true);

Eend:
            MessageBox.Show(str, "操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(false);
        }
예제 #4
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (DialogResult.No == MessageBox.Show("请确认要保存该工作人员信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string szNewPwd = MyTools.OpenString_To_HideString((textBox_pwd.Text + "        ").Substring(0, 8), MyStart.gszPwdKey);

            string szSql;
            string szTitle;
            string szErr = "";
            int    iRst;

            string[] szItem = comboBox_Cert.Text.Split(',');
            try
            {
                if (textBox_login.Enabled)//add
                {
                    szTitle = "工作人员基本信息-新增";
                    szSql   = "select * from sys_users where USER_LOGIN='******'";
                    DataSet ds = new DataSet();
                    iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr);
                    if (iRst < 0)
                    {
                        MessageBox.Show("查询信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                        goto Eend;
                    }
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        MessageBox.Show("登录帐号不能重复,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=登录帐号不能重复,请重新输入");
                        textBox_login.SelectAll();
                        textBox_login.Focus();
                        goto Eend;
                    }

                    szSql = "INSERT INTO sys_users(USER_LOGIN,USER_PWD,USER_TYPE,USER_NAME,USER_SEX,USER_BIRTH,CERT_TYPE,CERT_ID,"
                            + "USER_ADDR,USER_DPT,USER_POS,USER_TEL,USER_MOBILE,CITY,RMRK,USER_STAT,ADD_DT,USER_APP) VALUES "
                            + "('" + textBox_login.Text.Trim() + "','" + szNewPwd + "',2,'"
                            + textBox_Name.Text.Trim() + "','" + comboBox_Sex.Text.Trim() + "','" + dateTimePicker_birth.Value + "',"
                            + Convert.ToInt16(szItem[0]) + ",'" + textBox_Cert.Text.Trim() + "','" + textBox_Addr.Text.Trim() + "','"
                            + textBox_Dpt.Text.Trim() + "','" + textBox_Position.Text.Trim() + "','" + textBox_Tel.Text.Trim() + "','"
                            + textBox_Cell.Text.Trim() + "','ZHONGSHAN','" + textBox_Desc.Text.Trim() + "','USED',curtime(),'000000000000000000000000000000001')";
                }
                else//edit
                {
                    szTitle = "工作人员基本信息-修改";
                    szSql   = "UPDATE sys_users SET USER_PWD = '" + szNewPwd
                              + "',USER_SEX = '" + comboBox_Sex.Text.Trim()
                              + "',USER_BIRTH = '" + dateTimePicker_birth.Value
                              + "',CERT_TYPE = " + Convert.ToInt16(szItem[0])
                              + ",CERT_ID = '" + textBox_Cert.Text.Trim()
                              + "',USER_ADDR = '" + textBox_Addr.Text.Trim()
                              + "',USER_DPT = '" + textBox_Dpt.Text.Trim()
                              + "',USER_POS = '" + textBox_Position.Text.Trim()
                              + "',USER_TEL = '" + textBox_Tel.Text.Trim()
                              + "',USER_MOBILE = '" + textBox_Cell.Text.Trim()
                              + "',RMRK = '" + textBox_Desc.Text.Trim()
                              + "' WHERE USER_ID=" + textBox_Code.Text.Trim();
                }
                iRst = MyStart.oMyDb.WriteData(szSql, ref szErr);
                if (iRst < 1)
                {
                    MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr);
                }
                else
                {
                    szSql = "编号" + mszCode + "-姓名" + mszName;
                    MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID);

                    MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    GridDataRefresh();
                    //dataGridView1.Refresh();
                    MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK");
                }
                groupBoxInf.Enabled  = false;
                groupBoxList.Enabled = true;

                textBox_Code.Text = mszCode;
                textBox_Name.Text = mszName;
                textBox_Desc.Text = mszInf;
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Eend:
            MyStart.oMyDb.Close();
        }