Example #1
0
 private void selectListItems(InsPtn[] rels)
 {
     foreach (GridViewRowInfo gi in lstIns.Rows)
     {
         gi.Cells[0].Value = rels.Any(x => x.InsuranceId == (gi.DataBoundItem as Insurance).Id);
     }
 }
Example #2
0
        private void lstIns_CellValueChanged(object sender, GridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 0) return;

            Patient patient = patientBindingSource.DataSource as Patient;
            if (patient == null/*|| string.IsNullOrEmpty(patient.Code)*/) return;
            Insurance sc = lstIns.Rows[e.RowIndex].DataBoundItem as Insurance;
            if ((bool)e.Value)
            {
                if (patient.InsPtns.FirstOrDefault(item => item.InsuranceId == sc.Id) == null)
                {
                    InsPtn rel = new InsPtn();
                    rel.Patient = patient;
                    rel.InsuranceId = sc.Id;

                }
            }
            else
            {
                InsPtn i = patient.InsPtns.FirstOrDefault(item => item.Patient == patient && item.InsuranceId == sc.Id);
                if (i != null)
                    patient.InsPtns.Remove(i);

            }
        }