private void addTopRowToolStripMenuItem_Click(object sender, EventArgs e) { try { if (EquipmentGrid.GetFocusedRow() is EquipmentProfiles item) { UnitOfWork unitOfWork = new UnitOfWork(); var rowNumber = item.RowNumber; foreach (var i in unitOfWork.EquipmentProfilesRepo.Get(x => x.RefId == item.RefId && x.TableName == "TechSpecs" && x.RowNumber >= rowNumber)) { var eq = unitOfWork.EquipmentProfilesRepo.Find(x => x.Id == i.Id); eq.RowNumber = i.RowNumber + 1; unitOfWork.Save(); } unitOfWork = new UnitOfWork(); unitOfWork.EquipmentProfilesRepo.Insert(new EquipmentProfiles() { RefId = TechSpecsId, TableName = "TechSpecs", RowNumber = rowNumber, ParentItem = item.ParentItem }); unitOfWork.Save(); this.EquipmentProfileBindingSource.DataSource = unitOfWork.EquipmentProfilesRepo.Get(m => m.RefId == TechSpecsId && m.TableName == "TechSpecs", orderBy: x => x.OrderBy(m => m.RowNumber)); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (MessageBox.Show("Do you want to delete this?", "Submit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (EquipmentGrid.GetFocusedRow() is EquipmentProfiles item) { var unitOfWork = new UnitOfWork(); unitOfWork.EquipmentProfilesRepo.Delete(m => m.Id == item.Id && m.TableName == "Deliveries"); unitOfWork.Save(); } }