private void leafDataGridView_RowLeave(object sender, DataGridViewCellEventArgs e) { if (leafBindingSource?.Current == null) { return; } if (leafDataGridView.Rows.Count <= 1) { return; } if (!leafDataGridView.IsCurrentRowDirty) { return; } Validate(); ((Leaf)leafBindingSource.Current).EmployeeId = ((Empoyee)empoyeeBindingSource.Current).EmployeeId; leafBindingSource.EndEdit(); var iResult = LeaveManager.Save((Leaf)leafBindingSource.Current); if (iResult > 0) { LoadInitLeaves(); } }