private void btnUpdate_Click(object sender, EventArgs e) { ms.user.Name = txbName.Text; ms.user.Note = txbNote.Text; ms.user.DayOfBirth = dtpDayOfBirth.Value; client.Send(common.Serialize(ms)); this.Close(); }
private void btnChange_Click(object sender, EventArgs e) { if (valid()) { ms.user.Password = txbNewPass.Text; client.Send(common.Serialize(ms)); this.Close(); } }
private void btnRegister_Click(object sender, EventArgs e) { if (valid()) { ms.user.UserName = txbUsername.Text; ms.user.Password = txbPass.Text; client.Send(common.Serialize(ms)); this.Close(); } }
private void btnChange_Click(object sender, EventArgs e) { if (valid()) { ms.fileName = txbFileName.Text; client.Send(common.Serialize(ms)); this.Close(); } else { return; } }
void Send(string action) { ms.action = action; //add data ms.user.UserName = txbUsername.Text; ms.user.Password = txbPass.Text; ms.text = txbMessage.Text; ms.Uname = txbNameChat.Text; if (action == "upload") { string fileName = ""; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Multiselect = true; openFileDialog.InitialDirectory = ""; openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { foreach (string file in openFileDialog.FileNames) { fileName = Path.GetFileName(file); ms.fileName = fileName; //MessageBox.Show(ms.fileName); ms.data = null; ms.data = action == "upload" ? File.ReadAllBytes(file) : null; //client.Send(common.Serialize(ms)); frmFileName frm = new frmFileName(client, ms); frm.ShowDialog(); Thread.Sleep(1000); } } } } else if (action == "download") { string fileName = ""; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Multiselect = true; openFileDialog.InitialDirectory = ""; openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { foreach (string file in openFileDialog.FileNames) { fileName = Path.GetFileName(file); ms.fileName = fileName; //MessageBox.Show(ms.fileName); ms.data = null; ms.data = action == "download" ? null : File.ReadAllBytes(file); client.Send(common.Serialize(ms)); Thread.Sleep(1000); } } } } else { client.Send(common.Serialize(ms)); } }