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); }
private void listViewBooks_DoubleClick(object sender, EventArgs e) { int lineNumber = this.listView_Books.SelectedIndices[0]; var line = this.listView_Books.Items[lineNumber]; string bid = line.SubItems[0].Text; int id = int.Parse(bid); BookInformation book; if (!BookList.tryFind(id, out book)) { return; } BookEvaluaion rank; bool isNewComer = !BookEval.tryFind(id, out rank); Form_Item item = new Form_Item(book, rank, idNumeric, ucl, isNewComer); item.ReturnBook += (o, e1) => { if (!e1.CanUpdate) { return; } BookInformation info = e1.Book; BookEvaluaion value = e1.Rank; if (isNewComer) { BookEval.Add(value); } else { BookEval.ReplaceTo(id, value); } RefreshBookList(ref info, ref line); }; item.ShowDialog(); }
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); }