Exemplo n.º 1
0
        private void button_User_Click(object sender, EventArgs e)
        {
            User      person = new User(int.Parse(uid), uac, ucl, upw);
            Form_User user   = new Form_User(person);

            user.ReturnUser += (o, e1) =>
            {
                if (!e1.CanUpdate)
                {
                    return;
                }
                User now = e1.Me;
                // 更新资料
                string     question = "Change " + now.GetRawString(), answer;
                TcpClientP request = new TcpClientP();
                request.Connect(serverIP, Port.TCP_LOGIN_PORT);
                request.Query(question, out answer);
                if (answer != VerMessage.CHANGE_SUCCESS)
                {
                    MessageBox.Show("更新信息失败", "提示", MessageBoxButtons.OK);
                    request.Close();
                    return;
                }
                MessageBox.Show("更新信息成功", "提示", MessageBoxButtons.OK);
                request.Close();
                ucl = now.name;
                Registry.AddKey2Registry("PublishClient", "CurrentUserName", ucl);
                this.Text = "教材补助经费评估软件 [" + ucl + "]" + " [#" + uid + "]";
                this.label_ClientName.Text = "[#" + uid + "] " + ucl;
            };
            user.ShowDialog();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 关闭窗口时保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form_Login_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            tcpClientLogin.Close();
            tcpListenerUser.Stop();
            if (this.textBox_UesrAccount.Text == null)
            {
                return;
            }
            string lastUser = this.textBox_UesrAccount.Text;

            Registry.AddKey2Registry("PublishClient", "LastUser", lastUser);
        }
Exemplo n.º 3
0
        private void OnClientLogin(ref IPAddress where, ref string[] result, out string answer)
        {
            User client; answer = VerMessage.DEFAULT_RESPONSE;
            int  idx            = users.Find(result[1], out client);

            // 用户不存在
            if (idx == -1)
            {
                answer = VerMessage.LOGIN_FAILED_NO_SUCH_USER;
                return;
            }
            // 检查密码
            if (!client.testPassword(result[2]))
            {
                answer = VerMessage.LOGIN_FAILED_WRONG_PW;
                return;
            }
            // 发送用户个人资料
            tcpClientUserFile = new TcpClientP();
            tcpClientUserFile.Connect(new IPEndPoint(where, Port.TCP_USER_FILE_PORT));
            string data = client.toUserFile();

            tcpClientUserFile.Write(data);
            tcpClientUserFile.Close();
            // 加入连接列表
            Client login = new Client(where, client);

            onlineUsers.AddClient(login);
            Invoke(new AddUserIntoToListView_dele(AddUserIntoView), new object[] { client.account, client.name });
            // 反馈消息
            answer = VerMessage.LOGIN_SUCCESS;
        }
Exemplo n.º 4
0
 private void Form_Main_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
 {
     if (TryLogoff())
     {
         MessageBox.Show("登出成功", "Success", MessageBoxButtons.OK);
     }
     else
     {
         MessageBox.Show("登出失败", "Fail", MessageBoxButtons.OK);
     }
     tcpClientLogoff.Close();
     tcpServerGet.Stop();
 }
Exemplo n.º 5
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            List <IPAddress> targets = new List <IPAddress>();

            for (int i = 0, sz = listBox_Confirm.Items.Count; i < sz; i++)
            {
                string ucl = listBox_Confirm.Items[i].ToString();
                targets.Add(players.__table[facebook[ucl]].clientIP);
            }
            Parallel.ForEach(targets, (item, state, i) =>
            {
                TcpClientP home = new TcpClientP();
                home.Connect(new IPEndPoint(item, Port.TCP_BOOK_INFORMATION_PORT));
                home.Write(data);
                home.Close();
            });
            MessageBox.Show("所有数据发送完毕!", "提示", MessageBoxButtons.OK);
            this.Close();
        }
Exemplo n.º 6
0
        private void tSMI_Sendto_Click(object sender, EventArgs e)
        {
            BookEvaluaionList data = new BookEvaluaionList();

            for (int i = 0, sz = listView_Books.SelectedItems.Count; i < sz; i++)
            {
                string        id  = listView_Books.SelectedItems[i].SubItems[0].Text;
                BookEvaluaion tmp = new BookEvaluaion();
                BookEval.tryFind(int.Parse(id), out tmp);
                data.Add(tmp);
            }
            byte[] raw;
            ToBytes <BookEvaluaionList> .GetBytes(ref data, out raw);

            TcpClientP home = new TcpClientP();

            home.Connect(new IPEndPoint(serverIP, Port.TCP_BOOK_EVALUATION_PORT));
            home.Write(raw);
            home.Close();
            MessageBox.Show("发送成功", "提示", MessageBoxButtons.OK);
        }