Se creo el CRUD para ClsViajes con sus modelos y Procedimientos Almacenados

This commit is contained in:
AbrahamCastilloV
2023-12-11 08:53:56 -07:00
parent b8896b961a
commit 47caaa3997
8 changed files with 305 additions and 23 deletions

View File

@@ -95,16 +95,22 @@
</div>
</div>
</div>
<div class="row my-1" id="TrTipoUnidad" runat="server">
<div class="row margin-bottom-5" id="TrAF" runat="server">
<label class="col-md-4 bold">
<asp:Label ID="Label2" runat="server" Text="Tipo de Unidad:"></asp:Label></label><div
<asp:Label runat="server" Text="Transporte:"></asp:Label></label><div
class="col-md-8">
<asp:DropDownList ID="DdlUnidad"
runat="server" DataTextField="NombreComercial" DataValueField="CveCliente"
Class="table-group-action-input form-control input-inline input-sm select2me"
Width="75%" ValidationGroup="GrpGuardar">
<asp:DropDownList ID="DdlTransporte" AppendDataBoundItems="true" DataTextField="Descripcion"
DataValueField="CveActivoFijo" Class="table-group-action-input form-control input-inline text-center"
Width="200px" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVTransporte" runat="server" ControlToValidate="DdlTransporte"
Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Transporte''</b> es necesario, por favor ingréselo."
ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETransporte" runat="server" HighlightCssClass="vco"
TargetControlID="RFVTransporte" Width="400px" BehaviorID="_content_VCETransporte">
</ajax:ValidatorCalloutExtender>
</div>
</div>

View File

@@ -11,7 +11,17 @@ Partial Class ContratoTransportes
If Not IsPostBack Then
DdlClientes.setEsWebService(True)
'Lista Activos Fijos'
Dim ObjAF As New ClsAF()
If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then
If ObjAF.DtResultados.Rows.Count > 0 Then
DdlTransporte.DataSource = ObjAF.DtResultados
DdlTransporte.DataBind()
DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", ""))
End If
End If
ObjAF.Dispose()
If Not String.IsNullOrEmpty(Request.QueryString("CveContrato")) Then
Dim id As Integer = Convert.ToInt32(Request.QueryString("CveContrato"))

View File

@@ -9,6 +9,29 @@ Partial Class CrearViaje
If Not IsPostBack Then
CargaDatos()
If Not String.IsNullOrEmpty(Request.QueryString("CveViaje")) Then
Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje"))
Dim ObjViajes As New ClsViajes
If ObjViajes.GetViajes(CveViaje:=id) Then
Dim fecha As DateTime
If DateTime.TryParse(ObjViajes.Fecha.ToString, fecha) Then
TxtFechaViaje.Text = fecha.ToString("yyyy-MM-dd").Replace(" ", "T")
End If
DdlRutas.Text = ObjViajes.CveRuta.ToString
DdlTransporte.Text = ObjViajes.CveAF.ToString
DdlPartida.Text = ObjViajes.CvePartida.ToString
DdlDestino.Text = ObjViajes.CveDestino.ToString
DdlChofer.Text = ObjViajes.CvePersonal.ToString
BtnGuardar.Text = "Editar"
End If
End If
End If
End Sub
@@ -28,7 +51,6 @@ Partial Class CrearViaje
'Lista Rutas'
Dim ObjRutas As New ClsRutas()
If ObjRutas.GetRutas(-1, -1, -1, "", True, DateTime.Now) Then
Page.Response.Write("<script>console.log('El resultado de tu variable" + ObjRutas.DtResultados.Rows.ToString + "')</script>")
If ObjRutas.DtResultados.Rows.Count > 0 Then
DdlRutas.DataSource = ObjRutas.DtResultados
@@ -41,7 +63,6 @@ Partial Class CrearViaje
'Lista Destinos'
Dim ObjDestinos As New ClsDestinos()
If ObjDestinos.GetDestinos(-1, -1, -1, "", True, True, DateTime.Now) Then
Page.Response.Write("<script>console.log('El resultado de tu variable" + ObjDestinos.DtResultados.Rows.ToString + "')</script>")
If ObjDestinos.DtResultados.Rows.Count > 0 Then
@@ -63,10 +84,46 @@ Partial Class CrearViaje
End Sub
Protected Sub AddViaje(sender As Object, e As EventArgs)
Dim ObjViajes As New ClsViajes()
If ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa.ToEntero, TxtFechaViaje.Text.ToDate) = -1 Then
Alert("El Contrato se agregó correctamente.", TipoMensaje.MsgAdvertencia)
End If
Dim ObjViajes As New ClsViajes
ObjViajes.IniciaTransacSQL()
Try
If BtnGuardar.Text = "Guardar" Then
Dim CveContratoHijo As Integer = -1
CveContratoHijo = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero)
If CveContratoHijo > 0 Then
ObjViajes.Commit()
Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion)
DdlRutas.Text = ""
DdlTransporte.Text = ""
DdlChofer.Text = ""
TxtFechaViaje.Text = ""
DdlPartida.Text = ""
DdlDestino.SelectedValue = ""
End If
Else
Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje"))
If ObjViajes.UpdateViajes(id, DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) = True Then
Alert("El viaje se modificó correctamente.", TipoMensaje.MsgInformacion)
ObjViajes.Commit()
End If
End If
Catch ex As Exception
ObjViajes.RollBack()
Finally
ObjViajes.Dispose()
Response.Redirect("ListadoViajes.aspx")
End Try
End Sub
End Class

View File

@@ -41,6 +41,10 @@
<li>
<asp:HyperLink ID="LBCrearViaje" runat="server" NavigateUrl="CrearViaje.aspx"
Target="_blank"><i class='fa fa-car'></i> Crear Viaje</asp:HyperLink>
</li>
<li>
<asp:HyperLink ID="LBListadoViajes" runat="server" NavigateUrl="ListadoViajes.aspx"
Target="_blank"><i class='fa fa-road'></i> Listado de Viajes</asp:HyperLink>
</li>
</ContentTemplate>
</asp:UpdatePanel>

View File

@@ -0,0 +1,69 @@
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Site.master" CodeFile="ListadoViajes.aspx.vb"
Inherits="ListadoViajes" %>
<asp:Content ID="Content3" ContentPlaceHolderID="E" runat="Server">
Listado de Viajes</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style>
.my-1 {
margin-block: 1rem;
}
</style>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="C" runat="Server">
<contenttemplate>
<asp:GridView ID="GvViajes" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontró ningún viaje registrado"
CssClass="table table-striped table-hover Widthall ScrollAD text-center" GridLines="None"
data-sort="true" OnRowCommand="GvViajes_Comandos">
<Columns>
<asp:TemplateField HeaderText="Ruta">
<ItemTemplate>
<asp:Literal ID="LtlRuta" runat="server" Text='<%# Eval("Ruta") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Partida">
<ItemTemplate>
<asp:Literal ID="LtlPartida" runat="server" Text='<%# Eval("Partida") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Destino">
<ItemTemplate>
<asp:Literal ID="LtlDestino" runat="server" Text='<%# Eval("Destino") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fecha">
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Chofer">
<ItemTemplate>
<asp:Literal ID="LtlChofer" runat="server" Text='<%# Eval("Chofer") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Acciones">
<ItemTemplate>
<asp:Button ID="btnEditar" runat="server" Text="Editar" CommandName="Editar" class="btn btn-primary"
CommandArgument='<%# Eval("CveViaje") %>' />
<asp:Button ID="btnEliminar" runat="server" Text="Eliminar" CommandName="Eliminar"
class="btn btn-danger" CommandArgument='<%# Eval("CveViaje") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</contenttemplate>
</asp:Content>

View File

@@ -0,0 +1,56 @@
Option Explicit On
Option Strict On
Partial Class ListadoViajes
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
Dim ObjViajes As New ClsViajes
If ObjViajes.GetViajes() Then
GvViajes.DataSource = ObjViajes.DtResultados
Else
Me.GvViajes.DataSource = Nothing
End If
ObjViajes.Dispose()
GvViajes.DataBind()
Page.Response.Write("<script>console.log('El resultado de tu variable" + GvViajes.ToString + "')</script>")
End Sub
Protected Sub GvViajes_Comandos(sender As Object, e As GridViewCommandEventArgs)
Dim id As Integer = Convert.ToInt32(e.CommandArgument)
Dim url As String = $"CrearViaje.aspx?CveViaje={id}"
If e.CommandName = "Editar" Then
Dim script As String = $"window.open('{url}', '_blank');"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenWindow", script, True)
End If
If e.CommandName = "Eliminar" Then
Dim ObjViajes As New ClsViajes
ObjViajes.IniciaTransacSQL()
Try
ObjViajes.RemoveViaje(id)
ObjViajes.Commit()
Catch ex As Exception
ObjViajes.RollBack()
Finally
ObjViajes.Dispose()
Response.Redirect("ListadoViajes.aspx")
End Try
End If
End Sub
End Class