private void dataGridViewX1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (this._formMode != ViewModes.Add) { return; } MedicineDeliveryAllocationEntity ent = (MedicineDeliveryAllocationEntity)this.bindingSource1.Current; if (ent.SubNo != null) { return; } DeliveryAllocateDetail detailDialog = new DeliveryAllocateDetail(ent.MedicineDeliveryDetail); detailDialog.ShowDialog(this); if (detailDialog.DialogResult == DialogResult.Cancel) { return; } ent.MedicineDeliveryDetail.AllocatedWareHouseDetail = detailDialog.Result; var no = 1; this._medDeliveryAllocationList = new List <MedicineDeliveryAllocationEntity>(); foreach (var deliveryItem in this._medicineDeliveryDetailList) { // var allocatedList = this._mdecidineDeliveryDetailAllocate.Where(x => x.MedicineDeliveryDetailId == deliveryItem.Id).ToList(); var warehouse = this._warehouseList.FirstOrDefault(x => x.MedicineId == deliveryItem.MedicineId); var item = new MedicineDeliveryAllocationEntity(no++, deliveryItem, warehouse); this._medDeliveryAllocationList.Add(item); var subNo = 1; foreach (var itm in deliveryItem.AllocatedWareHouseDetail) { var subItem = new MedicineDeliveryAllocationEntity(subNo++, itm); _medDeliveryAllocationList.Add(subItem); } } this.bindingSource1.DataSource = this._medDeliveryAllocationList; this.bindingSource1.ResetBindings(true); this.dataGridViewX1.ResetBindings(); }
private void dataGridViewX1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (this._formMode != ViewModes.Add) return; MedicineDeliveryAllocationEntity ent = (MedicineDeliveryAllocationEntity) this.bindingSource1.Current; if (ent.SubNo != null) return; DeliveryAllocateDetail detailDialog = new DeliveryAllocateDetail(ent.MedicineDeliveryDetail); detailDialog.ShowDialog(this); if (detailDialog.DialogResult == DialogResult.Cancel) return; ent.MedicineDeliveryDetail.AllocatedWareHouseDetail = detailDialog.Result; var no = 1; this._medDeliveryAllocationList= new List<MedicineDeliveryAllocationEntity>(); foreach (var deliveryItem in this._medicineDeliveryDetailList) { // var allocatedList = this._mdecidineDeliveryDetailAllocate.Where(x => x.MedicineDeliveryDetailId == deliveryItem.Id).ToList(); var warehouse = this._warehouseList.FirstOrDefault(x => x.MedicineId == deliveryItem.MedicineId); var item = new MedicineDeliveryAllocationEntity(no++, deliveryItem, warehouse); this._medDeliveryAllocationList.Add(item); var subNo = 1; foreach (var itm in deliveryItem.AllocatedWareHouseDetail) { var subItem = new MedicineDeliveryAllocationEntity(subNo++, itm); _medDeliveryAllocationList.Add(subItem); } } this.bindingSource1.DataSource = this._medDeliveryAllocationList; this.bindingSource1.ResetBindings(true); this.dataGridViewX1.ResetBindings(); }