protected void BtnUpdateTravel_Click(object sender, EventArgs e) { Travel travelaux = (Travel)Session["CurrentTravel"]; Travel travel = new Travel(); travel.UserID = inputUserID.Text; travel.VehicleID = inputVehicleID.Text; travel.ConditionID = Convert.ToInt32(inputConditionID.Text); travel.created_at = travelaux.created_at; Session["CurrentTravel"] = null; ReferenceWSTravel.IwcfTravelsClient travelClient = new ReferenceWSTravel.IwcfTravelsClient(); travelClient.UpdateTravel(travel); travelClient.Close(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 3, "El usuario a actualizado el viaje " + travel.VehicleID, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El viaje ha sido actualizado', 'success', 4000);" + "}</script>"); }
private void GetUser(string UserID) { if (UserID != "") { ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); User user = userClient.FindUser(UserID); userClient.Close(); if (user != null) { inputName.Text = user.name; inputLastname.Text = user.lastname; inputEmail.Text = user.email; inputPhone.Text = user.phone; inputDateofborn.Text = user.dateofborn.ToString("dd/MM/yyyy"); inputNationality.SelectedValue = user.nationality; inputConditionID.SelectedValue = user.ConditionID.ToString(); inputRoleID.SelectedValue = user.RoleID.ToString(); inputDriverLicenseID.SelectedValue = user.DriverLicenseID.ToString(); HabilitarBotones(); } } else { DesHabilitarBotones(); } }
private void changePass(User user, string pass) { ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.UpdatePassword(user, pass); aux.InsertUserLog(user.UserID, 2, "El usuario a realizado el cambio de contraseña", DateTime.Now); aux.Close(); }
protected void BtnAddTravel_Click(object sender, EventArgs e) { User user = (User)Session["CurrentUser"]; Travel travel = new Travel(); travel.TravelID = 1; if (user.RoleID == 1) { travel.UserID = inputUserID.Text; } else { travel.UserID = user.UserID; } travel.VehicleID = inputVehicleID.Text; travel.ConditionID = Convert.ToInt32(inputConditionID.Text); travel.created_at = DateTime.Now; ReferenceWSTravel.IwcfTravelsClient travelClient = new ReferenceWSTravel.IwcfTravelsClient(); travelClient.AddTravel(travel); travelClient.Close(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 4, "El usuario a ingresado un viaje: " + travel.TravelID, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El viaje ha sido correctamente agregado: #" + travel.TravelID + ", 'success', 3000);" + "}</script>"); clearInputs(); }
private void GetUser(string UserID) { if (UserID != "") { ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); User user = userClient.FindUser(UserID); userClient.Close(); if (user != null) { inputName.Text = user.name + " " + user.lastname; Response.Write("<script>window.onload = function() {" + "showMsg('Se encontró correctamente este usuario ', 'success', 2000);" + "}</script>"); } else { Response.Write("<script>window.onload = function() {" + "showMsg('No se encontró este usuario ', 'warning', 2000);" + "}</script>"); DesHabilitarBotones(); } } else { Response.Write("<script>window.onload = function() {" + "showMsg('Error al insertar la cédula del usuario', 'warning', 2000);" + "}</script>"); DesHabilitarBotones(); } }
protected void BtnAddUser_Click(object sender, EventArgs e) { User user = new User(); user.UserID = inputUserID.Text; user.email = inputEmail.Text; user.passwd = "123cr456"; user.remember_token = RandomToken(); user.name = inputName.Text; user.lastname = inputLastname.Text; user.dateofborn = Convert.ToDateTime(inputDateofborn.Text); user.nationality = inputNationality.Text; user.phone = inputPhone.Text; user.created_at = Convert.ToDateTime(DateTime.Now); user.updated_at = Convert.ToDateTime(DateTime.Now); user.ConditionID = Convert.ToInt32(inputConditionID.Text); user.RoleID = Convert.ToInt32(inputRoleID.Text); user.DriverLicenseID = Convert.ToInt32(inputDriverLicenseID.Text); ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); userClient.AddUser(user); userClient.Close(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 2, "El usuario a ingresado al usuario " + user.UserID, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El usuario ha sido agregado', 'success', 4000);" + "}</script>"); clearInputs(); }
protected void BtnUpdateVehicle_Click(object sender, EventArgs e) { Vehicle vehicleAux = (Vehicle)Session["CurrentVehicle"]; Vehicle vehicle = new Vehicle(); vehicle.VehicleID = inputVehicleID.Text; vehicle.type = inputType.Text; vehicle.brand = inputBrand.Text; vehicle.year = Convert.ToDateTime(inputYear.Text); vehicle.engine = inputEngine.Text; vehicle.transmission = inputTransmission.Text; vehicle.fuel = inputFuel.Text; vehicle.fueltank = Convert.ToInt32(inputFuelTank.Text); vehicle.created_at = vehicleAux.created_at; vehicle.ConditionID = Convert.ToInt32(inputConditionID.Text); Session["CurrentVehicle"] = null; ReferenceWSVehicle.IwcfVehiclesClient vehicleClient = new ReferenceWSVehicle.IwcfVehiclesClient(); vehicleClient.UpdateVehicle(vehicle); vehicleClient.Close(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 3, "El usuario a actualizado al vehiculo " + vehicle.VehicleID, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El vehiculo ha sido actualizado', 'success', 4000);" + "}</script>"); }
protected void BtnAddLocation_Click(object sender, EventArgs e) { Location location = new Location(); location.name = inputName.Text; location.address = inputAddress.Text; location.latitude = inputLatitude.Text; location.longitude = inputLongitude.Text; location.TravelID = Convert.ToInt32(inputTravelID.Text); ReferenceWSLocation.IwcfLocationsClient locationClient = new ReferenceWSLocation.IwcfLocationsClient(); locationClient.AddLocation(location); locationClient.Close(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 4, "El usuario a ingresado una localización al viaje: " + location.TravelID, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('La localización ha sido correctamente agregada', 'success', 3000);" + "}</script>"); clearInputs(); }
protected void BtnAddVehicle_Click(object sender, EventArgs e) { ReferenceWSVehicle.IwcfVehiclesClient vehicleClient = new ReferenceWSVehicle.IwcfVehiclesClient(); Vehicle Auxvehicle = vehicleClient.FindVehicle(inputVehicleID.Text); vehicleClient.Close(); if (Auxvehicle == null) { Vehicle vehicle = new Vehicle(); vehicle.VehicleID = inputVehicleID.Text; vehicle.type = inputType.Text; vehicle.brand = inputBrand.Text; vehicle.year = Convert.ToDateTime("01-01-" + inputYear.Text); vehicle.engine = inputEngine.Text; vehicle.transmission = inputTransmission.Text; vehicle.fuel = inputFuel.Text; vehicle.fueltank = Convert.ToInt32(inputFuelTank.Text); vehicle.created_at = Convert.ToDateTime(DateTime.Now); vehicle.ConditionID = Convert.ToInt32(inputConditionID.Text); try { ReferenceWSVehicle.IwcfVehiclesClient vehicleClient2 = new ReferenceWSVehicle.IwcfVehiclesClient(); vehicleClient2.AddVehicle(vehicle); vehicleClient2.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El vehiculo ha sido agregado', 'success', 4000);" + "}</script>"); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 4, "El usuario a ingresado un vehiculo: " + vehicle.VehicleID, DateTime.Now); aux.Close(); } catch (Exception ex) { Console.WriteLine(ex); Response.Write("<script>window.onload = function() {" + "showMsg('Error al intentar ingresar vehiculo', 'warning', 2000);" + "}</script>"); } } else { Response.Write("<script>window.onload = function() {" + "showMsg('La placa de este vehiculo ya se encuentra registrada', 'warning', 4000);" + "}</script>"); } clearInputs(); }
public bool DeleteUser(string UserID) { try { ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); userClient.DeleteUser(UserID); userClient.Close(); return(true); } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
private void SignOut() { User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 1, "El usuario a cerrado la sesión", DateTime.Now); aux.Close(); Session["CurrentUser"] = null; Session.Clear(); Session.Abandon(); Response.Redirect("Login.aspx"); }
protected void BtnConsultar_Click(object sender, EventArgs e) { DateTime Fecha1 = Convert.ToDateTime(TxtFechaInicio.Text); DateTime Fecha2 = Convert.ToDateTime(TxtFechaFinal.Text); GridViewTravels.DataSource = logtravels.ListTravelsDate(Fecha1, Fecha2); GridViewTravels.DataBind(); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 5, "El usuario a consultado la lista viajes por fecha", DateTime.Now); aux.Close(); }
protected void BtnImprimir_click(object sender, EventArgs e) { Session["Formula"] = "{Vehicles.VehicleID} = '" + TxtVehicleID.Text + "'"; Session["Reporte"] = "ReportVehiclesID.rpt"; string _open = "window.open('ReportViewer.aspx', '_blank');"; ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), _open, true); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 2, "El usuario a generado un reporte de vehiculo por placa", DateTime.Now); aux.Close(); }
private void Log_in(string identification, string password) { try { User user = new User(); ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); user = userClient.ValidateUser(identification, password); userClient.Close(); if (user != null) { if (user.ConditionID == 1) { Session["CurrentUser"] = user; Session["Imsg"] = 0; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(user.UserID, 1, "El usuario a inicializado una sesión", DateTime.Now); aux.Close(); Response.Redirect("Index.aspx"); } else if (user.ConditionID == 2) { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario se encuentra inactivo', 'warning', 4000);" + "}</script>"); } else if (user.ConditionID == 3) { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario se encuentra suspendido', 'warning', 4000);" + "}</script>"); } } else { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario y/o la contraseña son incorrectos', 'warning', 4000);" + "}</script>"); } } catch (Exception ex) { Console.WriteLine(ex); Response.Write("<script>window.onload = function() {" + "showMsg('Error de Conexión!', 'danger', 4000).delay(2000);" + "}</script>"); } }
private void Forget(string identification) { try { User userAux = new User(); ReferenceWSUser.IwcfUsersClient userClient = new ReferenceWSUser.IwcfUsersClient(); userAux = userClient.FindUser(identification); userClient.Close(); if (userAux != null) { if (userAux.ConditionID == 1) { Session["AuxUser"] = userAux; Response.Redirect("RecoveryPassword.aspx"); } else if (userAux.ConditionID == 2) { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario se encuentra inactivo', 'warning', 4000);" + "}</script>"); } else if (userAux.ConditionID == 3) { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario se encuentra suspendido', 'warning', 4000);" + "}</script>"); } } else { Response.Write("<script>window.onload = function() {" + "showMsg('El usuario es incorrecto', 'warning', 4000);" + "}</script>"); } } catch (Exception ex) { Console.WriteLine(ex); Response.Write("<script>window.onload = function() {" + "showMsg('Error de Conexión!', 'danger', 4000).delay(2000);" + "}</script>"); } }
protected void BtnImprimir_Click(object sender, EventArgs e) { DateTime Fecha1 = Convert.ToDateTime(TxtFechaInicio.Text); DateTime Fecha2 = Convert.ToDateTime(TxtFechaFinal.Text); Session["Formula"] = "{Travels.created_at} >= date(" + Fecha1.Year + "," + Fecha1.Month + "," + Fecha1.Day + ") And {Travels.created_at} <=date(" + Fecha2.Year + "," + Fecha2.Month + "," + Fecha2.Day + ")"; Session["Reporte"] = "ReportTravelsDate.rpt"; Session["Fecha1"] = Convert.ToDateTime(TxtFechaInicio.Text); Session["Fecha2"] = Convert.ToDateTime(TxtFechaFinal.Text); string _open = "window.open('ReportViewer.aspx', '_blank');"; ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), _open, true); User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 2, "El usuario a generado un reporte de viajes por fecha", DateTime.Now); aux.Close(); }
protected void BtnDelTravel_Click(object sender, EventArgs e) { if (DeleteTravel(Convert.ToInt32(inputTravelID.Text))) { User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 2, "El usuario a eliminado el viaje: " + inputTravelID.Text, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El viaje fue correctamente eliminado', 'success', 3000);" + "}</script>"); } else { Response.Write("<script>window.onload = function() {" + "showMsg('Error al intentar eliminar usuario', 'warning', 2000);" + "}</script>"); } }
protected void BtnDelVehicle_Click(object sender, EventArgs e) { int i = DeleteVehicle(inputVehicleID.Text); if (i == 1) { User userAux = (User)Session["CurrentUser"]; ReferenceWSUser.IwcfUsersClient aux = new ReferenceWSUser.IwcfUsersClient(); aux.InsertUserLog(userAux.UserID, 3, "El usuario a eliminado al vehiculo: " + inputVehicleID.Text, DateTime.Now); aux.Close(); Response.Write("<script>window.onload = function() {" + "showMsg('El vehiculo fue correctamente eliminado', 'success', 3000);" + "}</script>"); } else { Response.Write("<script>window.onload = function() {" + "showMsg('Error al intentar eliminar vehiculo', 'warning', 2000);" + "}</script>"); } }