private async void Sb_AddOrUpdate_Click(object sender, EventArgs e) { if (!Dvp_Validate.Validate()) { return; } var student = new Student { StudentName = Te_Name.Text, Age = Convert.ToInt32(Te_Age.EditValue), BirthDay = De_BirthDay.DateTime, Class = Te_Class.Text, Contact = Te_Phone.Text, DepartmentId = Guid.Parse(Lue_Department.EditValue.ToString()), Email = Te_Email.Text, Sex = Rg_Sex.SelectedIndex == 1, StudentNo = Te_StudentNo.Text }; try { JsonMessageResult message; if (_addOrUpdate) { message = await _api.CreateStudent(student); } else { student.Id = Id; message = await _api.UpdateStudent(student); } if (message.ResultCode != 1) { XtraMessageBox.Show(message.ResultMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CloseForm(); XtraMessageBox.Show(message.ResultMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.None); } catch (Exception exception) { XtraMessageBox.Show(exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }