Пример #1
0
        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;
                }
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        private void ddlDriver_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            try
            {
                grdShifts.Rows.Clear();

                int DriverID = ddlDriver.SelectedValue.ToInt();

                objDriverMaster.GetByPrimaryKey(DriverID);


                //Fleet_Driver_Shift obj = General.GetObject<Fleet_Driver_Shift>(c => c.DriverId == DriverID);
                //if (obj != null)
                //{
                //    int ID = obj.Id.ToInt();

                //    objMaster.PrimaryKeyValue = ID;
                //}
                var data1 = objDriverMaster.Current.Fleet_Driver_Shifts.OrderBy(c => c.Id);
                var query = (from a in data1
                             select new
                {
                    Id = a.Id,
                    Shifts = a.Driver_Shift.ShiftName,
                    Shift_Id = a.Driver_Shift_ID,
                    FromTime = a.FromTime.Value.TimeOfDay,
                    ToTime = a.ToTime.Value.TimeOfDay
                }).AsQueryable();
                if (query.Count() > 0)
                {
                    //grdLister.DataSource = query.ToList();
                    DataTable dt = query.ToDataTable();
                    //for (int i = 0; i < grdShifts.Rows.Count; i++)
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        GridViewRowInfo row = null;

                        if (grdShifts.CurrentRow != null)
                        {
                            row = grdShifts.CurrentRow;
                        }

                        else
                        {
                            row = grdShifts.Rows.AddNew();
                        }
                        row.Cells[COL_SHIFT.SHIFT].Value    = dt.Rows[i]["Shifts"].ToStr();
                        row.Cells[COL_SHIFT.SHIFT_ID].Value = dt.Rows[i]["Shift_Id"].ToStr();
                        row.Cells[COL_SHIFT.FROMTIME].Value = dt.Rows[i]["FromTime"].ToStr();
                        row.Cells[COL_SHIFT.TOTIME].Value   = dt.Rows[i]["ToTime"].ToStr();
                        row.Cells[COL_SHIFT.ID].Value       = dt.Rows[i]["Id"].ToInt();
                        row.Cells[COL_SHIFT.MASTERID].Value = DriverID;



                        ClearShift();
                        //grdShifts.Rows[i].Cells["FROMTIME"].Value = dt.Rows[i]["FromTime"].ToStr();
                        //grdShifts.Rows[i].Cells["TOTIME"].Value = dt.Rows[i]["ToTime"].ToStr();
                    }
                }
                else
                {
                }
                dtpFromTime.Value = DateTime.Now.ToDateorNull();
                dtpTOTime.Value   = DateTime.Now.ToDateorNull();
            }
            catch (Exception ex)
            {
            }
        }