Exemple #1
0
        public ClsCarFleet GetCarFleetByCarFleetId(long lgCarFleetId)
        {
            ClsCarFleet objClsCarFleet = new ClsCarFleet();

            try
            {
                using (this.objDataContext = new CarFleetDataContext(Functions.StrConnection))
                {
                    GetCarFleetByIdResult item = this.objDataContext.GetCarFleetById(lgCarFleetId).ToList().FirstOrDefault();
                    if (item != null)
                    {
                        objClsCarFleet.inId             = item.ID;
                        objClsCarFleet.inOwner_Id       = item.Owner_Id;
                        objClsCarFleet.strLast_Trip     = item.Last_Trip.Replace(' ', '/');
                        objClsCarFleet.strCode          = item.Code;
                        objClsCarFleet.strReg           = item.Reg;
                        objClsCarFleet.strDesc          = item.Description;
                        objClsCarFleet.inColor_Id       = item.Color_Id;
                        objClsCarFleet.strFuel_Type     = item.Fuel_Type;
                        objClsCarFleet.inLast_Km        = item.Last_Km;
                        objClsCarFleet.strLast_Location = item.Last_Location;
                        objClsCarFleet.strMake          = item.Make;
                        objClsCarFleet.inFleetModels_Id = Convert.ToInt32(item.FleetModels_Id);
                    }
                }
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, mySession.Current.UserId);
            }

            return(objClsCarFleet);
        }
        public int SaveTracker(ClsTracker objSave, ClsCarFleet clsCarFleet)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (this.objDataContext = new TrackerDataContext(Functions.StrConnection))
                    {
                        var result = this.objDataContext.InsertOrUpdateTracker(objSave.inId, objSave.strTripStart,
                                                                               objSave.strTripEnd, objSave.strLocationStart, objSave.strLocationEnd,
                                                                               objSave.strReasonRemarks, objSave.inKmStart, objSave.inKmEnd, objSave.inKmDriven,
                                                                               objSave.inFuelStart, objSave.inFuelEnd, mySession.Current.UserId, objSave.strEntryMethod,
                                                                               true, objSave.blActive, PageMaster.Tracker.ToString().intSafe(), objSave.inCarId,
                                                                               objSave.lgReasonId, null, null, objSave.lgCompanyId, clsCarFleet.strReg, clsCarFleet.strCode,
                                                                               mySession.Current.Firstname, mySession.Current.Lastname)
                                     .FirstOrDefault();

                        if (result != null)
                        {
                            objSave.inId = result.InsertedId;
                        }
                    }

                    scope.Complete();
                }

                return(objSave.inId);
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Tracker, mySession.Current.UserId);
                return(0);
            }
        }
Exemple #3
0
        public int SaveCarFleet(ClsCarFleet objSave)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (this.objDataContext = new CarFleetDataContext(Functions.StrConnection))
                    {
                        var result = this.objDataContext.InsertOrUpdateCarFleet(objSave.inId, objSave.inOwner_Id, objSave.strCode, objSave.strReg, objSave.strDesc, objSave.inColor_Id,
                                                                                objSave.strFuel_Type, objSave.strLast_Trip, objSave.inLast_Km, objSave.strLast_Location, objSave.inFleetModels_Id, objSave.inFleetMakes_Id, mySession.Current.UserId, PageMaster.CarFleet.ToString().intSafe(), null, null).FirstOrDefault();

                        if (result != null)
                        {
                            objSave.inId = result.InsertedId;
                        }
                    }

                    scope.Complete();
                }

                return(objSave.inId);
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, mySession.Current.UserId);
                return(0);
            }
        }