ListView 拖拽

private void ListView1_MouseMove(object sender, MouseEventArgs e)
{
Patientappointment appointment = ListView1.SelectedItem as Patientappointment;
if (appointment != null)
{
SelectedAppointment = appointment;
if (e.LeftButton == MouseButtonState.Pressed)
{
DragDrop.DoDragDrop(ListView1, appointment, DragDropEffects.Link);
}
}
}

private void ListView1_PreviewDragOver(object sender, DragEventArgs e)
{
Patientappointment appointment = e.OriginalSource as Patientappointment;
e.Effects = appointment == null ? DragDropEffects.None : DragDropEffects.Link;
}

private void ListView2_PreviewDrop(object sender, DragEventArgs e)
{
if (selectedAppointment != null)
{
selectedAppointment.Status = "checkin";
AppointmentAction appointmentAction = new AppointmentAction();
appointmentAction.UpdatePatientappointment(selectedAppointment);
patientappointmentCollection.Remove(selectedAppointment);

PatientAction patientAction = new PatientAction();
Patientmain patientmain = patientAction.ReadPatientmain(selectedAppointment.Patientid);
if (patientmain != null)
{
Outpatient outpatient = new Outpatient();
outpatient.Outpatientid = Guid.NewGuid().ToString();
outpatient.Patientid = selectedAppointment.Patientid;
outpatient.Patientname = selectedAppointment.Patientname;
outpatient.Doctorid = selectedAppointment.Doctorid;
outpatient.Doctorname = selectedAppointment.Doctorname;
outpatient.Appointmentid = selectedAppointment.Appointmentid;
outpatient.Checkintime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
outpatient.Contactphone = selectedAppointment.Contactphone;
outpatient.Gender = patientmain.Gender;
outpatient.Age = DateTime.Now.Year - Convert.ToDateTime(patientmain.Birthday).Year + "";
outpatient.Createddate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
outpatient.Creatorid = SysGlobal.ActiveUser.UserID;
outpatient.Status = "checkin";
OutpatientAction outpatientAction = new OutpatientAction();
outpatientAction.AddOutpatient(outpatient);
outpatientCollection.Add(outpatient);
}
}
}

ListView 拖拽

上一篇:[开发笔记]-C#获取pdf文档的页数


下一篇:在MingW下编译llvm/clang