void grdDriverShift_CommandCellClick(object sender, EventArgs e) { try { GridCommandCellElement gridCell = (GridCommandCellElement)sender; RadGridView grid = gridCell.GridControl; if (gridCell.ColumnInfo.Name == "btnUpdate") { //if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete a Cost Center ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) //{ int Id = this.grdDriverShift.CurrentRow.Cells[COLS.Id].Value.ToInt(); //string.Format("{0:HH:mm}", a.FromTime), bool IsActiveDriver = grdDriverShift.CurrentRow.Cells[COLS.IsActive].Value.ToBool(); DateTime?dtFrom = grdDriverShift.CurrentRow.Cells[COLS.Date].Value.ToDate(); TimeSpan FromTime = grdDriverShift.CurrentRow.Cells[COLS.FromTime].Value.ToDateTime().TimeOfDay; DateTime?FromDateTime = dtFrom + FromTime; TimeSpan ToTime = grdDriverShift.CurrentRow.Cells[COLS.ToTime].Value.ToDateTime().TimeOfDay; DateTime?ToDateTime = dtFrom + ToTime; if (FromDateTime > ToDateTime) { ENUtils.ShowMessage("Start time can't greater then end time"); return; } objDriverShifts.GetByPrimaryKey(Id); objDriverShifts.Edit(); objDriverShifts.Current.FromTime = FromDateTime; objDriverShifts.Current.ToTime = ToDateTime; objDriverShifts.Current.IsActive = IsActiveDriver; objDriverShifts.Save(); objDriverShifts.Clear(); PopulateData(); // } } else //if (gridCell.ColumnInfo.Name == "btnDelete") { if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Driver Shift ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { int Id = this.grdDriverShift.CurrentRow.Cells[COLS.Id].Value.ToInt(); objDriverShifts.GetByPrimaryKey(Id); objDriverShifts.Delete(objDriverShifts.Current); grdDriverShift.CurrentRow.Delete(); } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void grid_CommandCellClick(object sender, EventArgs e) { GridCommandCellElement gridCell = (GridCommandCellElement)sender; if (gridCell.ColumnInfo.Name.ToLower() == "btndelete") { if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete Shift ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question)) { objMaster.GetByPrimaryKey(grdShifts.CurrentRow.Cells["Id"].Value.ToLong()); if (objMaster.Current != null) { objMaster.Delete(objMaster.Current); RadGridView grid = gridCell.GridControl; grid.CurrentRow.Delete(); } else { RadGridView grid = gridCell.GridControl; grid.CurrentRow.Delete(); } } } }