public DriverMaster GetDriverMasterRecord(string recordID, string UserSNo)
        {
            DriverMaster driverMaster = new DriverMaster();

            SqlParameter[] Parameters = { new SqlParameter("@SNo", Convert.ToInt32(recordID)), new SqlParameter("@UserID", Convert.ToInt32(UserSNo)) };
            SqlDataReader  dr         = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordDriverMaster", Parameters);

            if (dr.Read())
            {
                driverMaster.SNo              = Convert.ToInt32(dr["SNo"]);
                driverMaster.ID               = dr["ID"].ToString().ToUpper().ToUpper();
                driverMaster.Nationality      = dr["Nationality"].ToString().ToUpper();
                driverMaster.Text_Nationality = dr["Text_Nationality"].ToString().ToUpper();
                driverMaster.FirstName        = dr["FirstName"].ToString().ToUpper();
                driverMaster.LastName         = dr["LastName"].ToString().ToUpper();
                driverMaster.Mobile           = dr["Mobile"].ToString();
                //    driverMaster.Active = dr["Active"].ToString();

                if (!String.IsNullOrEmpty(dr["IsActive"].ToString()))
                {
                    driverMaster.IsActive = Convert.ToBoolean(dr["IsActive"]);
                    driverMaster.Active   = dr["Active"].ToString().ToUpper();
                }
                driverMaster.UpdatedBy = dr["UpdatedUser"].ToString();
                driverMaster.CreatedBy = dr["CreatedUser"].ToString();
            }

            dr.Close();
            return(driverMaster);
        }
 public TcpClients(DriverMaster driverMaster, string name, string ip, string port, string type, Configurations c)
 {
     this.driverMaster = driverMaster;
     this.name         = name;
     this.ip           = ip;
     this.port         = Convert.ToInt32(port);
     this.type         = type;
     this.c            = c;
 }
Пример #3
0
 public Udp(DriverMaster driverMaster, string name, string enlaceport, string destinationport, string type, Configurations c)
 {
     this.driverMaster    = driverMaster;
     this.name            = name;
     this.enlaceport      = int.Parse(enlaceport);
     this.destinationport = int.Parse(destinationport);
     this.type            = type;
     this.c = c;
 }
 public UdpClients(DriverMaster driverMaster, string name, string ip, string enlaceport, string destinationport, string type, Configurations c)
 {
     this.driverMaster    = driverMaster;
     this.name            = name;
     this.ip              = ip;
     this.enlaceport      = Convert.ToInt32(enlaceport);
     this.destinationport = Convert.ToInt32(destinationport);
     this.type            = type;
     this.c = c;
 }
Пример #5
0
 public Tcp(DriverMaster driverMaster, string name, string port, string type, Configurations c)
 {
     this.name          = name;
     this.port          = int.Parse(port);
     this.type          = type;
     this.driverMaster  = driverMaster;
     this.xmlConnection = new XmlConnection();
     xmlConnection._CreateXml();
     this.c = c;
 }
 public FormServidor()
 {
     InitializeComponent();
     d = DriverMaster.myDriverMasterClass;
     d.setFormServidor(this);
     toolTip.SetToolTip(pictureInformation, "Los botones switch sirven para cerrar todos\n" +
                        "los canales de comunicacion del socket, si desea \n" +
                        "cerrar uno en particular de clic al nombre del socket\n" +
                        "al cual pertenece el canal, ahi podrá encontrar\n" +
                        "la configuracion individual y podrá activar y desactivar\n" +
                        "el canal");
 }
        public FormSocketTcpClient(FormServidor formServidor)
        {
            InitializeComponent();
            this.Text            = string.Empty;
            this.ControlBox      = false;
            this.DoubleBuffered  = true;
            this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;

            c = new Configurations();
            this.formServidor = formServidor;
            this.driverMaster = formServidor.d;
        }
Пример #8
0
 public bool SaveDriver(DriverModel model)
 {
     try
     {
         if (model != null)
         {
             DriverMaster driver = new DriverMaster();
             driver.name                   = model.name;
             driver.drivercategory         = model.drivercategory;
             driver.isreliable             = model.isreliable;
             driver.DOB                    = model.DOB;
             driver.Religion               = model.Religion;
             driver.qualification          = model.qualification;
             driver.maritalstatus          = model.maritalstatus;
             driver.drivinglicencecategory = model.drivinglicencecategory;
             driver.drivinglicenceNo       = model.drivinglicenceNo;
             driver.drivLiceIssueAuthoLoca = model.drivLiceIssueAuthoLoca;
             driver.drivLiceExDate         = model.drivLiceExDate;
             driver.bloodgroup             = model.bloodgroup;
             driver.Address                = model.Address;
             driver.state                  = model.state;
             driver.city                   = model.city;
             driver.STDcode                = model.STDcode;
             driver.phoneno                = model.phoneno;
             driver.mobileno               = model.mobileno;
             driver.referencename          = model.referencename;
             driver.referenceaddress       = model.referenceaddress;
             driver.referencecity          = model.referencecity;
             driver.referencepincode       = model.referencepincode;
             driver.referencemobileno      = model.referencemobileno;
             driver.referencephoneno       = model.referencephoneno;
             driver.policyno               = model.policyno;
             driver.insurancecompany       = model.insurancecompany;
             driver.insurancevalue         = model.insurancevalue;
             driver.nomination             = model.nomination;
             driver.insuranceexpirydate    = model.insuranceexpirydate;
             driver.fileupload             = model.fileupload;
             driver.isActive               = true;
             tRSEntities4.DriverMasters.Add(driver);
             tRSEntities4.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #9
0
 public FormPrincipal()
 {
     InitializeComponent();
     formPrincipal = this;
     driverMaster  = new DriverMaster();
     driverMaster.setInactive();
     driverMaster.beginAllSockets();
     leftBorderBtn      = new Panel();
     leftBorderBtn.Size = new Size(7, 66);
     panelMenu.Controls.Add(leftBorderBtn);
     this.Text            = string.Empty;
     this.ControlBox      = false;
     this.DoubleBuffered  = true;
     this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
 }
Пример #10
0
        public ActionResult Create(DriverMaster vm)
        {
            if (vm.DriverID > 0)
            {
                db.Entry(vm).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                db.DriverMasters.Add(vm);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Пример #11
0
        public ActionResult Create(int id = 0)
        {
            ViewBag.Supplier    = db.SupplierMasters.ToList();
            ViewBag.Vehicles    = db.VehicleMasters.ToList();
            ViewBag.Vehicletype = db.VehicleTypes.ToList();
            ViewBag.Title       = "Driver Master - Create";
            DriverMaster vm = new DriverMaster();

            if (id > 0)
            {
                ViewBag.Title = "DriverMaster - Modify";
                vm            = db.DriverMasters.Find(id);
                if (vm.SupplierID != null)
                {
                    var supplier = db.SupplierMasters.Find(vm.SupplierID);
                    if (supplier != null)
                    {
                        ViewBag.SupplierName = supplier.SupplierName;
                    }
                }

                if (vm.VehicleID != null)
                {
                    var vechicle = db.VehicleMasters.Find(vm.VehicleID);
                    if (vechicle != null)
                    {
                        ViewBag.RegNo = vechicle.RegistrationNo;
                    }
                }
            }
            else
            {
                ViewBag.SupplierName = "";
            }

            return(View(vm));
        }
        /// <summary>
        /// Method to add driver - SS
        /// </summary>
        /// <param name="addDriverMaster">driver detail</param>
        /// <param name="loggedInUser">logged in user</param>
        /// <returns>response</returns>
        public async Task <DriverMasterManagementResponse> AddDriverMasterAsync(AddDriverMasterManagementAc addDriverMaster,
                                                                                ApplicationUser loggedInUser)
        {
            if (string.IsNullOrEmpty(addDriverMaster.Name) && string.IsNullOrEmpty(addDriverMaster.Name.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "Name can't be empty", ErrorType = DriverMasterManagementResponseType.Name
                       }
            }
            ;
            else if (string.IsNullOrEmpty(addDriverMaster.MobileNumber) && string.IsNullOrEmpty(addDriverMaster.MobileNumber.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "Mobile number can't be empty", ErrorType = DriverMasterManagementResponseType.MobileNumber
                       }
            }
            ;
            else if (string.IsNullOrEmpty(addDriverMaster.LicenseNumber) && string.IsNullOrEmpty(addDriverMaster.LicenseNumber.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "License number can't be empty", ErrorType = DriverMasterManagementResponseType.LicenseNumber
                       }
            }
            ;
            else if (string.IsNullOrEmpty(addDriverMaster.LicenseType) && string.IsNullOrEmpty(addDriverMaster.LicenseType.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "License type can't be empty", ErrorType = DriverMasterManagementResponseType.LicenseType
                       }
            }
            ;
            else if (string.IsNullOrEmpty(addDriverMaster.PlaceOfIssue) && string.IsNullOrEmpty(addDriverMaster.PlaceOfIssue.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "Place of issue can't be empty", ErrorType = DriverMasterManagementResponseType.PlaceOfIssue
                       }
            }
            ;
            else if (string.IsNullOrEmpty(addDriverMaster.IssuingAuthority) && string.IsNullOrEmpty(addDriverMaster.IssuingAuthority.Trim()))
            {
                return new DriverMasterManagementResponse()
                       {
                           HasError = true, Message = "Issuing authority can't be empty", ErrorType = DriverMasterManagementResponseType.IssuingAuthority
                       }
            }
            ;
            else
            {
                var user = await _userManager.FindByNameAsync(addDriverMaster.MobileNumber);

                var instituteId = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true);

                bool isUserExist = false;
                if (user != null)
                {
                    isUserExist = await _iMSDbContext.DriverMasters.AnyAsync(x => x.UserId == user.Id && x.InstituteId == instituteId);
                }
                if (isUserExist)
                {
                    return new DriverMasterManagementResponse()
                           {
                               HasError = true, Message = "Driver with this mobile number already exist", ErrorType = DriverMasterManagementResponseType.MobileNumber
                           }
                }
                ;
                else
                {
                    #region Add User
                    if (user == null)
                    {
                        var password = "******";
                        user = new ApplicationUser()
                        {
                            CreatedBy = loggedInUser.Id,
                            CreatedOn = DateTime.UtcNow,
                            UserName  = addDriverMaster.MobileNumber,
                            Name      = addDriverMaster.Name,
                            UpdatedOn = DateTime.UtcNow,
                            UpdatedBy = loggedInUser.Id
                        };
                        await _userManager.CreateAsync(user, password);
                    }
                    else
                    {
                        if (await _iMSDbContext.Institutes.AnyAsync(x => x.Id == instituteId && x.AdminId == user.Id))
                        {
                            return new DriverMasterManagementResponse()
                                   {
                                       HasError = true, ErrorType = DriverMasterManagementResponseType.MobileNumber, Message = "Monile number is already linked up with admin. Admin can't be driver"
                                   }
                        }
                        ;
                    }
                    _iMSDbContext.UserInstituteMappings.Add(new UserInstituteMapping()
                    {
                        CreatedOn   = DateTime.UtcNow,
                        InstituteId = instituteId,
                        IsActive    = false,
                        UserId      = user.Id
                    });

                    await _iMSDbContext.SaveChangesAsync();

                    #endregion

                    #region Add Driver
                    var driver = new DriverMaster()
                    {
                        Address          = addDriverMaster.Address,
                        CreatedOn        = DateTime.UtcNow,
                        DateOfBirth      = addDriverMaster.DateOfBirth,
                        DateOfIssue      = addDriverMaster.DateOfIssue,
                        InstituteId      = await _instituteUserMappingHelperService.GetUserCurrentSelectedInstituteIdAsync(loggedInUser.Id, true),
                        IsDriver         = addDriverMaster.IsDriver,
                        IssuingAuthority = addDriverMaster.IssuingAuthority,
                        LicenseNumber    = addDriverMaster.LicenseNumber,
                        LicenseType      = addDriverMaster.LicenseType,
                        MobileNumber     = addDriverMaster.MobileNumber,
                        Name             = addDriverMaster.Name,
                        PlaceOfIssue     = addDriverMaster.PlaceOfIssue,
                        Salary           = addDriverMaster.Salary,
                        UpdatedById      = loggedInUser.Id,
                        UpdatedOn        = DateTime.UtcNow,
                        ValidityTill     = addDriverMaster.ValidityTill,
                        UserId           = user.Id
                    };
                    _iMSDbContext.DriverMasters.Add(driver);
                    await _iMSDbContext.SaveChangesAsync();

                    #endregion
                    return(new DriverMasterManagementResponse()
                    {
                        HasError = false, Message = "Driver added successfully", Data = new { Id = driver.Id }
                    });
                }
            }
        }
        public async Task <dynamic> GetDriverDashboardDetails(string currentUserId, int currentUserInstituteId)
        {
            DriverMaster driver = await _iMSDbContext.DriverMasters.FirstOrDefaultAsync(x => x.UserId.Equals(currentUserId) && x.InstituteId == currentUserInstituteId);

            if (driver != null)
            {
                List <DomainModel.Models.VehicleDriverMapping> vehicleDriverMappingsList = await _iMSDbContext.VehicleDriverMappings
                                                                                           .Where(x => x.DriverId == driver.Id)
                                                                                           .Include(x => x.Vehicle)
                                                                                           .ToListAsync();

                List <int> vehicleIdsList = vehicleDriverMappingsList.Select(x => x.Vehicle.Id).Distinct().ToList();

                List <VehicleAccident> vehicleAccidents = await _iMSDbContext.VehicleAccidents.Where(x => vehicleIdsList.Contains(x.VehicleId))
                                                          .Include(x => x.Vehicle).ToListAsync();

                List <VehicleMaintenance> vehicleMaintanances = await _iMSDbContext.VehicleMaintenances.Where(x => vehicleIdsList.Contains(x.VehicleId))
                                                                .Include(x => x.Vehicle).ToListAsync();

                List <VehicleRepair> vehicleRepairs = await _iMSDbContext.VehicleRepairs.Where(x => vehicleIdsList.Contains(x.VehicleId))
                                                      .Include(x => x.Vehicle).ToListAsync();

                List <VehicleAccidentMaintenanceAc> vehicleAccidentMaintenanceDetailsList = new List <VehicleAccidentMaintenanceAc>();

                foreach (VehicleAccident vehicleAccident in vehicleAccidents)
                {
                    vehicleAccidentMaintenanceDetailsList.Add(new VehicleAccidentMaintenanceAc
                    {
                        Type          = "Accident",
                        Date          = vehicleAccident.AccidentDate,
                        EstimatedCost = vehicleAccident.EstimateCost,
                        VehicleNumber = vehicleAccident.Vehicle.VehicleCode
                    });
                }

                foreach (VehicleMaintenance vehicleMaintanance in vehicleMaintanances)
                {
                    vehicleAccidentMaintenanceDetailsList.Add(new VehicleAccidentMaintenanceAc
                    {
                        Type          = "Maintenance",
                        Date          = vehicleMaintanance.MaintenanceDate,
                        EstimatedCost = vehicleMaintanance.EstimateCost,
                        VehicleNumber = vehicleMaintanance.Vehicle.VehicleCode
                    });
                }

                foreach (VehicleRepair vehicleRepair in vehicleRepairs)
                {
                    vehicleAccidentMaintenanceDetailsList.Add(new VehicleAccidentMaintenanceAc
                    {
                        Type          = "Repair",
                        Date          = vehicleRepair.RepairDate,
                        EstimatedCost = vehicleRepair.RepairCost,
                        VehicleNumber = vehicleRepair.Vehicle.VehicleCode
                    });
                }

                return(new
                {
                    VehiclesList = vehicleDriverMappingsList,
                    VehicleAccidentMaintenanceDetailsList = vehicleAccidentMaintenanceDetailsList
                });
            }
            return(null);
        }