void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove) { objMaster = new DriverBO(); try { objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt()); objMaster.Delete(objMaster.Current); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } e.Cancel = true; } } }
public override void Save() { try { if (grdDriver.CurrentRow == null) { ENUtils.ShowMessage("Please select any Driver"); return; } int DriverId = grdDriver.CurrentRow.Cells[COLS.Id].Value.ToInt(); objDriver.GetByPrimaryKey(DriverId); objDriver.Edit(); string[] skipProperties = { "Fleet_Driver", "Driver_Shift", "Fleet_VehicleType", "Fleet_Driver_Note", "Gen_DebitCreditNote", "Fleet_DriverVehicleDetail", "Fleet_Master" }; IList <Fleet_Driver_Shift> savedList3 = objDriver.Current.Fleet_Driver_Shifts; List <Fleet_Driver_Shift> listofDetail3 = (from r in grdShift.Rows.Where(c => c.Cells[COLS.Check].Value.ToBool() == true) select new Fleet_Driver_Shift { Id = r.Cells[COLS.Id].Value.ToInt(), DriverId = DriverId, Driver_Shift_ID = r.Cells[COLS.Driver_Shift_ID].Value.ToIntorNull(), //FromTime = r.Cells[COLS.FromTime].Value.ToDateTimeorNull(), //ToTime = r.Cells[COLS.TillTime].Value.ToDateTimeorNull(), //DayValues = r.Cells[COLS.DayValues].Value.ToStr() }).ToList(); Utils.General.SyncChildCollection(ref savedList3, ref listofDetail3, "Id", skipProperties); objDriver.Save(); } catch (Exception ex) { if (objDriver.Errors.Count > 0) { ENUtils.ShowMessage(objDriver.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }