using DevExpress.XtraEditors; using HL_FristAidPlatform_DTO; using HL_FristAidPlatform_Public; using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; namespace HL_FristAidPlatform_PreHospitalEmergency { public partial class Form_OwnerlessPersonnel : XtraForm { private string Guid; public Form_OwnerlessPersonnel(string guid) { InitializeComponent(); Guid = guid; } private void Form_OwnerlessPersonnel_Load(object sender, EventArgs e) { DataTable dt = DBHelpClass.Get(string.Format("api/admin/T_SYS_User/GetDriver?hospitalGuid={0}", Information.Hospital.GUID)); checkedListBoxControl1.DataSource = dt;//显示分页结果 this.checkedListBoxControl1.DisplayMember = "Name"; this.checkedListBoxControl1.ValueMember = "GUID"; DataTable dt1 = DBHelpClass.Get(string.Format("api/admin/T_SYS_User/GetDoctor?hospitalGuid={0}", Information.Hospital.GUID)); checkedListBoxControl2.DataSource = dt1;//显示分页结果 this.checkedListBoxControl2.DisplayMember = "Name"; this.checkedListBoxControl2.ValueMember = "GUID"; DataTable dt2 = DBHelpClass.Get(string.Format("api/admin/T_SYS_User/GetNurse?hospitalGuid={0}", Information.Hospital.GUID)); checkedListBoxControl3.DataSource = dt2;//显示分页结果 this.checkedListBoxControl3.DisplayMember = "Name"; this.checkedListBoxControl3.ValueMember = "GUID"; } private void simpleButton1_Click(object sender, EventArgs e) { List list = new List(); PlanDrvingPersonnelDTO model = new PlanDrvingPersonnelDTO(); model.GUID = Guid; model.PerList= ""; string strCollected = string.Empty; if (checkedListBoxControl1.CheckedItems.Count<=0) { XtraMessageBox.Show("至少选择一个司机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (checkedListBoxControl1.CheckedItems.Count >1) { XtraMessageBox.Show("最多选择一个司机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (checkedListBoxControl2.CheckedItems.Count <= 0) { XtraMessageBox.Show("至少选择一个医生", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (checkedListBoxControl2.CheckedItems.Count > 1) { XtraMessageBox.Show("最多选择一个医生", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (checkedListBoxControl3.CheckedItems.Count <= 0) { XtraMessageBox.Show("至少选择一个护士", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (checkedListBoxControl3.CheckedItems.Count > 1) { XtraMessageBox.Show("最多选择一个护士", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < checkedListBoxControl1.CheckedItems.Count; i++) { if (!string.IsNullOrEmpty(model.PerList)) { model.PerList += ","; } model.PerList += checkedListBoxControl1.CheckedItems[i].ToString(); } for (int i = 0; i < checkedListBoxControl2.CheckedItems.Count; i++) { if (!string.IsNullOrEmpty(model.PerList)) { model.PerList += ","; } model.PerList += checkedListBoxControl2.CheckedItems[i].ToString(); } for (int i = 0; i < checkedListBoxControl3.CheckedItems.Count; i++) { if (!string.IsNullOrEmpty(model.PerList)) { model.PerList += ","; } model.PerList += checkedListBoxControl3.CheckedItems[i].ToString(); } list.Add(model); string url = string.Empty; url = "api/admin/T_SYS_User/VehiclePersonnelPlan"; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); // var sendData = JsonConvert.SerializeObject(list); //访问 ListEntity t = client.Post(url,list); if (t.Success) { XtraMessageBox.Show("分配成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_VehicleManagement f1; f1 = (Form_VehicleManagement)this.Owner; f1.BindDate(); this.Close(); } } } }