Ejemplo n.º 1
0
 private void skinButtonComfirmModifyPwd_Click(object sender, EventArgs e)
 {
     if (textBoxModifiedPassword.Text == "")
     {
         MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     ProcTestData.Password[comboBoxAllUsers.SelectedIndex] = textBoxModifiedPassword.Text;
     ProcTestData.ModifyUserPassword(ProcTestData.Account[comboBoxAllUsers.SelectedIndex], ProcTestData.Password[comboBoxAllUsers.SelectedIndex]);
     MessageBox.Show(comboBoxAllUsers.SelectedItem.ToString() + " 密码已设置成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Ejemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (ProcTestData.IsConnectInternet() == false)
            {
                MessageBox.Show("网络未连接!\r\n请确认连接后重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Application.Run(new dfu_Form());
            //Application.Run(new MainForm());
        }
Ejemplo n.º 3
0
 private void skinButtonDeleteUser_Click(object sender, EventArgs e)
 {
     if (comboBoxAllUsers.SelectedItem.ToString() == "Admin")
     {
         MessageBox.Show("此用户为管理用户\r\n不可删除!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (MessageBox.Show("确认删除用户:" + comboBoxAllUsers.SelectedItem.ToString() + "\r\n此操作不能撤回!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         ProcTestData.DeleteUser(comboBoxAllUsers.SelectedItem.ToString());
         ProcTestData.Account.RemoveAt(comboBoxAllUsers.SelectedIndex);
         ProcTestData.Password.RemoveAt(comboBoxAllUsers.SelectedIndex);
         comboBoxAllUsers.Items.RemoveAt(comboBoxAllUsers.SelectedIndex);
         textBoxModifiedPassword.Text = "";
     }
 }
Ejemplo n.º 4
0
        private void skinButton_Login_Click(object sender, EventArgs e)
        {
            if (textBox_UserName.Text == null)
            {
                MessageBox.Show("用户名不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (textBox_LoginCode.Text == null)
            {
                MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            for (int i = 0; i < ProcTestData.Account.Count; i++)
            {
                if (textBox_UserName.Text == ProcTestData.Account[i])
                {
                    if (textBox_LoginCode.Text == ProcTestData.Password[i])
                    {
                        ProcTestData.PresentAccount = ProcTestData.Account[i];
                        ProcTestData.WriteLastUserName(ProcTestData.lastLoginUserFile, ProcTestData.PresentAccount);

                        this.Hide();
                        if ((radioButton1.Checked == true) && (radioButton2.Checked == false))
                        {
                            MainForm fm = new MainForm();
                            fm.Show();
                        }
                        else
                        {
                            X6Forms fm = new X6Forms();
                            fm.Show();
                        }
                        return;
                    }
                }
            }

            MessageBox.Show("请检查用户名与密码是否正确", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            textBox_UserName.Text  = "";
            textBox_LoginCode.Text = "";
        }
Ejemplo n.º 5
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            try
            {
                ProcTestData.Account  = ProcTestData.GetMysqlUserInfo("user");
                ProcTestData.Password = ProcTestData.GetMysqlUserInfo("password");

                if (ProcTestData.Account == null)
                {
                    MessageBox.Show("用户信息读取失败", "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }


                textBox_UserName.Text = ProcTestData.ReadLastUserName(ProcTestData.lastLoginUserFile);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 6
0
        private void SendSetGwAddr(string addrStr)
        {
            try
            {
                //string[] addr = addrStr.Split('.');
                //byte[] data = new byte[addr.Length];

                //for (int i = 0; i < data.Length; i++)
                //{
                //    data[i] = Convert.ToByte(addr[i]);
                //}

                string str  = ProcTestData.fillString(addrStr, 10, '0', 0);
                byte[] data = ProcTestData.stringToBCD(str);
                //byte[] data = Encoding.Default.GetBytes(addr);
                SendSerialData(MakeSendArray((byte)DFU_Command.CMD_FW_UPDATE_SEND, data));
            }
            catch (Exception ex)
            {
                //updateText("异常:" + ex.Message);
            }
        }
Ejemplo n.º 7
0
        private static byte[] MakeSendArray(byte cmd, byte[] data)
        {
            UInt16      length;
            List <byte> list = new List <byte> {
            };

            byte[] srtDes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            list.Add(0xAA);
            list.Add(0x55);

            list.AddRange(srtDes);
            byte ver = 0x01;

            dfu_serial_number++;

            if (data != null)
            {
                length = (UInt16)(1 + 1 + 1 + data.Length + 1);
            }
            else
            {
                length = 2;
            }

            list.Add((byte)(length));
            list.Add((byte)(length >> 8));
            list.Add(ver);
            list.Add(dfu_serial_number);
            list.Add(cmd);
            if (data != null)
            {
                list.AddRange(data);
            }

            list.Add(ProcTestData.caculatedCRC(list.ToArray(), list.Count));

            return(list.ToArray());
        }
Ejemplo n.º 8
0
        private void skinButtonAddUser_Click(object sender, EventArgs e)
        {
            if (textBoxUserName.Text != "" && textBoxPassword.Text != "")
            {
                if (ProcTestData.Account.Contains(textBoxUserName.Text) == false)
                {
                    ProcTestData.Account.Add(textBoxUserName.Text);
                    ProcTestData.Password.Add(textBoxPassword.Text);

                    ProcTestData.AddUserAndPassword(textBoxUserName.Text, textBoxPassword.Text);
                    MessageBox.Show("已添加" + textBoxUserName.Text, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    comboBoxAllUsers.Items.Add(textBoxUserName.Text);
                }
                else
                {
                    MessageBox.Show("账号已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBoxUserName.Text = "";
                }
            }
            else
            {
                MessageBox.Show("账号或密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 9
0
        private void DFU_RECEIVE_DataProc(byte[] data)
        {
            byte[] buf = new byte[data.Length];
            Array.Copy(data, buf, data.Length);

            try
            {
                if (buf.Length > 17)
                {
                    for (int i = 0; i < buf.Length; i++)
                    {
                        if (buf[i] == 0xAA && buf[i + 1] == 0x55)
                        {
                            length = (buf[i + 12]) + (buf[i + 13] << 8) + 14;
                            if (buf.Length >= (length + i))
                            {
                                byte   checkSum   = buf[length + i - 1];
                                byte[] validFrame = new byte[length];

                                Array.Copy(buf, i, validFrame, 0, validFrame.Length);

                                byte calcCRC = ProcTestData.caculatedCRC(validFrame, validFrame.Length - 1);

                                //if (X6MsgDebug)
                                //{
                                //    string receive = "";
                                //    for (int j = 0; j<validFrame.Length; j++)
                                //    {
                                //        receive += validFrame[j].ToString("X2") + " ";
                                //    }
                                //    //LOG("Receive: " + receive);

                                //}

                                if (calcCRC == checkSum)
                                {
                                    arraybuffer.Clear();

                                    byte cmd = validFrame[16];

                                    switch (cmd)
                                    {
                                    //case (byte) X6Command.TestMode://测试模式请求
                                    //    X6MessageTestModeHandle(validFrame);
                                    //    Thread.Sleep(500);
                                    //    break;

                                    case (byte)DFU_Command.CMD_FW_UPDATE_REQ:

                                        break;

                                    case (byte)DFU_Command.CMD_FW_UPDATE_SEND:

                                        break;

                                    default:
                                        break;
                                    }
                                }
                                else
                                {
                                    //LOG("recv data err");
                                    //if (X6MsgDebug)
                                    //{
                                    //    string receive = "";
                                    //    for (int j = 0; j<validFrame.Length; j++)
                                    //    {
                                    //        receive += validFrame[j].ToString("X2") + " ";
                                    //    }
                                    //    LOG("Receive: " + receive);
                                    //}
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }