示例#1
0
        void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                objMaster = new VehicleTypeBO();

                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;
                }
            }
        }
        private void Save()
        {
            try
            {
                int orderNo = 1;



                if (lstVehicleOrder.Items[0].Value.ToInt() != AppVars.objPolicyConfiguration.DefaultVehicleTypeId.ToInt())
                {
                    ENUtils.ShowMessage("Default Vehicle should be on Top in the order");
                    return;
                }


                foreach (RadListDataItem item in lstVehicleOrder.Items)
                {
                    //    objMaster = new ZoneBO();
                    objMaster.GetByPrimaryKey(item.Value);

                    if (objMaster.Current != null)
                    {
                        objMaster.CheckDataValidation = false;
                        objMaster.Current.OrderNo     = orderNo++;

                        objMaster.Save();
                    }
                }


                General.RefreshListWithoutSelected <frmVehicleTypeList>("frmVehicleTypeList1");

                Close();

                //General.LoadZoneList();
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }
        public override void Save()
        {
            try
            {
                IsSaved = false;
                if (objMaster.PrimaryKeyValue == null)
                {
                    objMaster.New();
                    Fleet_VehicleType objVehicle = General.GetQueryable <Fleet_VehicleType>(null).OrderByDescending(c => c.Id).FirstOrDefault();
                    if (objVehicle != null)
                    {
                        //   objMaster.Current.Id = objVehicle.Id+1;
                        objMaster.Current.OrderNo = objVehicle.Id + 1;
                    }
                }
                else
                {
                    objMaster.Edit();
                }

                objMaster.Current.VehicleType         = txtVehicleType.Text.Trim();
                objMaster.Current.NoofPassengers      = numPassengers.Value.ToInt();
                objMaster.Current.NoofLuggages        = numLuggages.Value.ToInt();
                objMaster.Current.NoofHandLuggages    = numHandLuggages.Value.ToInt();
                objMaster.Current.StartRate           = numStartRate.Value.ToDecimal();
                objMaster.Current.StartRateValidMiles = numValidMiles.Value.ToDecimal();
                objMaster.Current.Photo = pic_Vehicle.GetByteArrayOfImage();

                objMaster.Current.BackgroundColor = txtBgColor.Tag.ToStr();
                objMaster.Current.TextColor       = txtTextColor.Tag.ToStr();


                DateTime dateValue = new DateTime(1900, 1, 1, 0, 0, 0);

                DateTime?fromPeakTimeStartTime  = null;
                DateTime?tillPeakTimeStartTime  = null;
                DateTime?fromOffPeakFromEndTime = null;
                DateTime?tillOffPeakToEndTime   = null;


                if (dtpFromStartTime.Value != null)
                {
                    fromPeakTimeStartTime = string.Format("{0:dd/MM/yyyy HH:mm}", dateValue.ToDate() + dtpFromStartTime.Value.Value.TimeOfDay).ToDateTime();
                }

                if (dtpTillStartTime.Value != null)
                {
                    tillPeakTimeStartTime = string.Format("{0:dd/MM/yyyy HH:mm}", dateValue.ToDate() + dtpTillStartTime.Value.Value.TimeOfDay).ToDateTime();
                }


                if (dtpFromEndTime.Value != null)
                {
                    fromOffPeakFromEndTime = string.Format("{0:dd/MM/yyyy HH:mm}", dateValue.ToDate() + dtpFromEndTime.Value.Value.TimeOfDay).ToDateTime();
                }

                if (dtpTillEndTime.Value != null)
                {
                    tillOffPeakToEndTime = string.Format("{0:dd/MM/yyyy HH:mm}", dateValue.ToDate() + dtpTillEndTime.Value.Value.TimeOfDay).ToDateTime();
                }


                //  objMaster.Current.EnablePeakOffPeak = chkEnablePeakFares.Checked;
                objMaster.Current.FromStartTime = fromPeakTimeStartTime;
                objMaster.Current.TillStartTime = tillPeakTimeStartTime;

                objMaster.Current.FromStartRate           = numFromStartRate.Value.ToDecimal();
                objMaster.Current.FromStartRateValidMiles = numFromValidMiles.Value.ToDecimal();

                objMaster.Current.FromEndTime = fromOffPeakFromEndTime;
                objMaster.Current.TillEndTime = tillOffPeakToEndTime;

                objMaster.Current.TillStartRate           = numTillStartRate.Value.ToDecimal();
                objMaster.Current.TillStartRateValidMiles = numTillValidMiles.Value.ToDecimal();

                objMaster.Current.DriverWaitingChargesPerHour  = numDrvWaitingCharges.Value.ToDecimal();
                objMaster.Current.AccountWaitingChargesPerHour = numAccountWaitingChargesMins.Value.ToDecimal();


                objMaster.Save();

                IsSaved = true;
                General.RefreshListWithoutSelected <frmVehicleTypeList>("frmVehicleTypeList1");
            }
            catch (Exception ex)
            {
                if (objMaster.Errors.Count > 0)
                {
                    ENUtils.ShowMessage(objMaster.ShowErrors());
                }
                else
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
        }