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);
            }
        }
        public override void Save()
        {
            try
            {
                DateTime?From          = dtpStartTime.Value.ToDateTimeorNull();
                DateTime?To            = dtpToTime.Value.ToDateTimeorNull();
                string   error         = string.Empty;
                int?     DriverShiftID = ddlShifts.SelectedValue.ToInt();
                int?     DayNo         = 0;
                if (ddlDays.SelectedItem != null)
                {
                    DayNo = ddlDays.SelectedIndex.ToInt();
                }
                else
                {
                    error = "Required : Day";
                }
                if (lstDayWiseDriver.Items.Count == 0)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error = "Required : Drivers to Add Shift";
                    }
                    else
                    {
                        error += Environment.NewLine + "Required : Drivers to Add Shift";
                    }
                }
                if (From == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error = "Required : From Time";
                    }
                    else
                    {
                        error += Environment.NewLine + "Required : From Time";
                    }
                }
                if (To == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error = "Required : To Time";
                    }
                    else
                    {
                        error += Environment.NewLine + "Required : To Time";
                    }
                }
                if (DriverShiftID == 0)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error = "Required : Driver Shift";
                    }
                    else
                    {
                        error += Environment.NewLine + "Required : Driver Shift";
                    }
                }



                //if (To != null && To < from)
                if (From.Value.Hour <= 12 && To.Value.Hour <= 12)
                {
                    if (To < From)
                    {
                        if (string.IsNullOrEmpty(error))
                        {
                            error = "Required : To Time must be greater than End Time";
                        }
                        else
                        {
                            error += Environment.NewLine + "Required : To Time must be greater than End Time";
                        }
                    }
                }
                else if (From.Value.Hour > 12 && To.Value.Hour > 12)
                {
                    if (To < From)
                    {
                        if (string.IsNullOrEmpty(error))
                        {
                            error = "Required : To Time must be greater than End Time";
                        }
                        else
                        {
                            error += Environment.NewLine + "Required : To Time must be greater than End Time";
                        }
                    }
                }

                if (!string.IsNullOrEmpty(error))
                {
                    ENUtils.ShowMessage(error);
                    return;
                }


                for (int i = 0; i < lstDayWiseDriver.Items.Count; i++)
                {
                    int DriverId = lstDayWiseDriver.Items[i].Value.ToInt();

                    //var query = General.GetObject<Fleet_Driver_Shift>(c => c.DriverId == DriverId && ((c.FromTime>=From.ToDateTimeorNull()) && (c.ToTime>=To.ToDateTimeorNull())));// && (c.Driver_Shift_ID==DriverShiftID)));// && (c.FromTime >=From.ToDate()) &&  (c.Driver_Shift_ID==DriverShiftID)); //|| (c.ToTime == To.ToDate())).Id;// || (c.Driver_Shift_ID == DriverShiftID));
                    // var query = General.GetObject<Fleet_Driver_Shift>(c => c.DriverId == DriverId && ((c.FromTime > From) ||(c.ToTime>From) || (c.ToTime >= To)));

                    var query = General.GetObject <Fleet_Driver_Shift>(c => c.DriverId == DriverId && ((c.ToTime >= From) || (c.ToTime >= To)));
                    //if (query != null)
                    //{
                    //    if (query.FromTime > From && query.FromTime > To && query.ToTime > From && query.FromTime > To)
                    //    {
                    //        objDriverShifts.New();
                    //        objDriverShifts.Current.DriverId = DriverId;
                    //        objDriverShifts.Current.FromTime = From;
                    //        objDriverShifts.Current.ToTime = To;
                    //        objDriverShifts.Current.IsActive = true;
                    //        objDriverShifts.Current.DayNo = DayNo;
                    //        objDriverShifts.Current.Driver_Shift_ID = DriverShiftID;
                    //        objDriverShifts.Save();
                    //    }
                    //}
                    if (query == null)
                    {
                        objDriverShifts.New();
                        objDriverShifts.Current.DriverId        = DriverId;
                        objDriverShifts.Current.FromTime        = From;
                        objDriverShifts.Current.DayNo           = DayNo;
                        objDriverShifts.Current.ToTime          = To;
                        objDriverShifts.Current.IsActive        = true;
                        objDriverShifts.Current.Driver_Shift_ID = DriverShiftID;
                        objDriverShifts.Save();
                        //  objDriverShifts.Clear();
                    }
                }
                this.Close();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }