490 lines
23 KiB
VB.net
490 lines
23 KiB
VB.net
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
|
|
Partial Class Acarreos_ContratosAcarreos
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
Private Property CveAcarreoProyecto As Integer
|
|
Get
|
|
If ViewState("CveAcarreoProyecto") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveAcarreoProyecto").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAcarreoProyecto") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveMaterial As Integer
|
|
Get
|
|
If ViewState("CveMaterial") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveMaterial").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMaterial") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveTarifa As Integer
|
|
Get
|
|
If ViewState("CveTarifa") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveTarifa").ToString.ToEntero
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTarifa") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DTTarifa As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("DTTarifa")), Nothing, CType(ViewState("DTTarifa"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTTarifa") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DTMaterialVolumen As DataTable
|
|
Get
|
|
Return If(IsNothing(ViewState("DTMaterialVolumen")), Nothing, CType(ViewState("DTMaterialVolumen"), DataTable))
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTMaterialVolumen") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaDdlSubProyectoOrigen()
|
|
CargaDdlSubProyectoDestino()
|
|
CargaDdlMaterial()
|
|
CargaDdlTransportista()
|
|
CargaDdlUnidadMedida()
|
|
CreaTmpTarifas()
|
|
CreaTmpMaterialVolumen()
|
|
TxtFechaInicio.Text = Now.AddDays(0).ToShortDateString
|
|
TxtFechaFin.Text = Now.AddDays(0).ToShortDateString
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
CveAcarreoProyecto = IfNull(Request("CveAcarreoProyecto"), "-1").ToString.ToEntero
|
|
BtnAgregarContratoAcarreo.Text = "Agregar Contrato"
|
|
If CveAcarreoProyecto <> -1 Then
|
|
Dim ObjAcar As New ClsAcarreos
|
|
If ObjAcar.GetAcarreosProyectos(CveAcarreoProyecto, UsuarioActual.CveEmpresa, -1, "-1") Then
|
|
Dim dr As DataRow = ObjAcar.DtResultados.Rows(0)
|
|
CargaGvMaterialVolumen()
|
|
CargaGvTarifa()
|
|
DdlSubProyectoDestino.SelectedValue = dr("CveSubProyectoDestino").ToString
|
|
DdlSubProyectoOrigen.SelectedValue = dr("CveSubProyectoOrigen").ToString
|
|
TxtDescripcion.Text = dr("Descripcion").ToString
|
|
TxtNumContrato.Text = dr("NumContrato").ToString
|
|
TxtFechaInicio.Text = dr("FechaInicio").ToString.ToDate
|
|
TxtFechaFin.Text = dr("FechaFin").ToString.ToDate
|
|
BtnAgregarContratoAcarreo.Text = "Guardar Cambios"
|
|
DTMaterialVolumen = GvMaterialVolumen.DataSource
|
|
DTTarifa = GvTarifa.DataSource
|
|
End If
|
|
ObjAcar.Dispose()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub BtnAgregarTarifa_Click(sender As Object, e As EventArgs) Handles BtnAgregarTarifa.Click
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTarifa"))
|
|
HdnModalidadTarifa.Value = "A"
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Public Sub DeleteTarifa_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
DTTarifa.AcceptChanges()
|
|
DTTarifa.Rows(GvRow.RowIndex.ToEntero).Delete()
|
|
DTTarifa.AcceptChanges()
|
|
GvTarifa.DataSource = DTTarifa
|
|
GvTarifa.DataBind()
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaGvTarifa()
|
|
Dim ObjAcar As New ClsAcarreos()
|
|
If ObjAcar.GetAcarreosTarifas(CveAcarreoProyecto, UsuarioActual.CveEmpresa) Then
|
|
DTTarifa = ObjAcar.DtResultados
|
|
GvTarifa.DataSource = DTTarifa
|
|
GvTarifa.DataBind()
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Private Sub CreaTmpTarifas()
|
|
DTTarifa = New DataTable
|
|
DTTarifa.Columns.Add("CveTransportista", GetType(Integer))
|
|
DTTarifa.Columns.Add("CveMaterial", GetType(Integer))
|
|
DTTarifa.Columns.Add("Material", GetType(String))
|
|
DTTarifa.Columns.Add("Transportista", GetType(String))
|
|
DTTarifa.Columns.Add("Tarifa", GetType(Double))
|
|
DTTarifa.Columns.Add("DistanciaInicio", GetType(Double))
|
|
DTTarifa.Columns.Add("DistanciaFin", GetType(Double))
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarMaterialVolumen_Click(sender As Object, e As EventArgs) Handles BtnAgregarMaterialVolumen.Click
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddMaterial"))
|
|
HdnModalidadMaterial.Value = "A"
|
|
UpMaterialVolumen.Update()
|
|
End Sub
|
|
|
|
Public Sub DeleteMaterialVolumen_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
DTMaterialVolumen.AcceptChanges()
|
|
DTMaterialVolumen.Rows(GvRow.RowIndex.ToEntero).Delete()
|
|
DTMaterialVolumen.AcceptChanges()
|
|
GvMaterialVolumen.DataSource = DTMaterialVolumen
|
|
GvMaterialVolumen.DataBind()
|
|
UpMaterialVolumen.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaGvMaterialVolumen()
|
|
Dim ObjAcar As New ClsAcarreos()
|
|
If ObjAcar.GetAcarreosMaterialVolumen(CveAcarreoProyecto, UsuarioActual.CveEmpresa, -1) Then
|
|
DTMaterialVolumen = ObjAcar.DtResultados
|
|
GvMaterialVolumen.DataSource = DTMaterialVolumen
|
|
GvMaterialVolumen.DataBind()
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Private Sub CreaTmpMaterialVolumen()
|
|
DTMaterialVolumen = New DataTable
|
|
DTMaterialVolumen.Columns.Add("CveUnidadMedida", GetType(Integer))
|
|
DTMaterialVolumen.Columns.Add("UnidadMedida", GetType(String))
|
|
DTMaterialVolumen.Columns.Add("CveMaterial", GetType(Integer))
|
|
DTMaterialVolumen.Columns.Add("Material", GetType(String))
|
|
DTMaterialVolumen.Columns.Add("Volumen", GetType(Double))
|
|
DTMaterialVolumen.Columns.Add("Presupuesto", GetType(Double))
|
|
DTMaterialVolumen.Columns.Add("VolumenTipo", GetType(Double))
|
|
End Sub
|
|
|
|
Private Sub CargaDdlSubProyectoOrigen()
|
|
DdlSubProyectoOrigen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubProyectoOrigen.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)
|
|
DdlSubProyectoOrigen.DataBind()
|
|
UpProyecto.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDdlSubProyectoDestino()
|
|
DdlSubProyectoDestino.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubProyectoDestino.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1)
|
|
DdlSubProyectoDestino.DataBind()
|
|
UpProyecto.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDdlUnidadMedida()
|
|
DdlUnidadMedida.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
DdlUnidadMedida.DataBind()
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDdlMaterial()
|
|
Dim ObjAcar As New ClsAcarreos()
|
|
If ObjAcar.GetMaterial(-1, 1, UsuarioActual.CveEmpresa) Then
|
|
DdlMaterial.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlMaterial.DataSource = ObjAcar.DtResultados
|
|
DdlMaterial.DataBind()
|
|
DdlMaterialTarifa.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlMaterialTarifa.DataSource = ObjAcar.DtResultados
|
|
DdlMaterialTarifa.DataBind()
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpMaterialVolumen.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDdlTransportista()
|
|
Dim ObjAcar As New ClsAcarreos()
|
|
If ObjAcar.GetTransportista(-1, UsuarioActual.CveEmpresa, 1) Then
|
|
DdlTransportista.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlTransportista.DataSource = ObjAcar.DtResultados
|
|
DdlTransportista.DataBind()
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpTarifas.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarContratoAcarreo_Click(sender As Object, e As EventArgs) Handles BtnAgregarContratoAcarreo.Click
|
|
If DdlSubProyectoDestino.SelectedValue = "-1" Then
|
|
Alert("Debe seleccionar un proyecto destino.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf DdlSubProyectoOrigen.SelectedValue = "-1" Then
|
|
Alert("Debe seleccionar un proyecto origen.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf GvTarifa.Rows.Count = 0 Then
|
|
Alert("Debe introducir una tarifa.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf GvMaterialVolumen.Rows.Count = 0 Then
|
|
Alert("Debe introducir un material.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Dim ErrorClasif As Boolean = False
|
|
Dim ObjAcar As New ClsAcarreos
|
|
Dim _CveAcarreoProyecto As Integer
|
|
ObjAcar.IniciaTransacSQL()
|
|
If CveAcarreoProyecto <> -1 Then
|
|
|
|
|
|
If Not ObjAcar.RemoveAcarreosMaterialVolumen(CveAcarreoProyecto) Then
|
|
ErrorClasif = True
|
|
End If
|
|
|
|
If Not ObjAcar.RemoveAcarreosTarifas(CveAcarreoProyecto) Then
|
|
ErrorClasif = True
|
|
End If
|
|
|
|
If Not ObjAcar.UpdateAcarreosProyectos(CveAcarreoProyecto, DdlSubProyectoOrigen.SelectedValue, DdlSubProyectoDestino.SelectedValue, TxtFechaInicio.Text, TxtFechaFin.Text, TxtNumContrato.Text, TxtDescripcion.Text, UsuarioActual.CveUsuario) Then
|
|
ErrorClasif = True
|
|
End If
|
|
For Each Gvr As GridViewRow In GvMaterialVolumen.Rows
|
|
If Not ObjAcar.AddAcarreosMaterialVolumen(Gvr.DataKey("CveMaterial").ToEntero, Gvr.DataKey("Volumen"), Gvr.DataKey("Presupuesto"), Gvr.DataKey("VolumenTipo"), CveAcarreoProyecto, Gvr.DataKey("CveUnidadMedida").ToEntero) Then
|
|
ErrorClasif = True
|
|
End If
|
|
Next
|
|
For Each Gvr As GridViewRow In GvTarifa.Rows
|
|
If Not ObjAcar.AddAcarreosTarifas(Gvr.DataKey("Tarifa"), Gvr.DataKey("DistanciaInicio"), Gvr.DataKey("DistanciaFin"), CveAcarreoProyecto, Gvr.DataKey("CveTransportista"), Gvr.DataKey("CveMaterial")) Then
|
|
ErrorClasif = True
|
|
End If
|
|
Next
|
|
Else
|
|
If Not ObjAcar.AddAcarreosProyectos(DdlSubProyectoOrigen.SelectedValue, DdlSubProyectoDestino.SelectedValue, TxtFechaInicio.Text, TxtFechaFin.Text, UsuarioActual.CveEmpresa, TxtNumContrato.Text, TxtDescripcion.Text, UsuarioActual.CveUsuario) Then
|
|
ErrorClasif = True
|
|
End If
|
|
_CveAcarreoProyecto = ObjAcar._CveAcarreoProyecto
|
|
For Each Gvr As GridViewRow In GvMaterialVolumen.Rows
|
|
If Not ObjAcar.AddAcarreosMaterialVolumen(Gvr.DataKey("CveMaterial").ToEntero, Gvr.DataKey("Volumen"), Gvr.DataKey("Presupuesto"), Gvr.DataKey("VolumenTipo"), _CveAcarreoProyecto, Gvr.DataKey("CveUnidadMedida").ToEntero) Then
|
|
ErrorClasif = True
|
|
End If
|
|
Next
|
|
For Each Gvr As GridViewRow In GvTarifa.Rows
|
|
If Not ObjAcar.AddAcarreosTarifas(Gvr.DataKey("Tarifa"), Gvr.DataKey("DistanciaInicio"), Gvr.DataKey("DistanciaFin"), _CveAcarreoProyecto, Gvr.DataKey("CveTransportista"), Gvr.DataKey("CveMaterial")) Then
|
|
ErrorClasif = True
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ErrorClasif = False Then
|
|
ObjAcar.Commit()
|
|
If CveAcarreoProyecto <> -1 Then
|
|
Response.Redirect($"/Acarreos/ContratosAcarreos.aspx?&Actualizar={"1"}", True)
|
|
Else
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
DdlMaterial.SelectedIndex = -1
|
|
DdlMaterialTarifa.SelectedIndex = -1
|
|
DdlSubProyectoDestino.SelectedIndex = -1
|
|
DdlSubProyectoOrigen.SelectedIndex = -1
|
|
DdlTransportista.SelectedIndex = -1
|
|
DdlUnidadMedida.SelectedIndex = -1
|
|
TxtDistanciaFin.Text = ""
|
|
TxtDistanciaInicio.Text = ""
|
|
TxtFechaFin.Text = ""
|
|
TxtFechaInicio.Text = ""
|
|
TxtPresupuesto.Text = ""
|
|
TxtTarifa.Text = ""
|
|
TxtVolumen.Text = ""
|
|
TxtVolumenTipo.Text = ""
|
|
TxtDescripcion.Text = ""
|
|
TxtNumContrato.Text = ""
|
|
TxtFechaInicio.Text = Now.AddDays(0).ToShortDateString
|
|
TxtFechaFin.Text = Now.AddDays(0).ToShortDateString
|
|
DTTarifa.Rows.Clear()
|
|
DTMaterialVolumen.Rows.Clear()
|
|
GvTarifa.DataSource = Nothing
|
|
GvTarifa.DataBind()
|
|
GvMaterialVolumen.DataSource = Nothing
|
|
GvMaterialVolumen.DataBind()
|
|
UpTarifas.Update()
|
|
UpProyecto.Update()
|
|
UpMaterialVolumen.Update()
|
|
UpAgregar.Update()
|
|
End If
|
|
Else
|
|
ObjAcar.RollBack()
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarTarifaModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarTarifaModal.Click
|
|
|
|
Dim ErrorAgregar As Boolean = False
|
|
If DdlTransportista.SelectedValue = "-1" Then
|
|
Alert("Debe seleccionar un transportista.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf DdlMaterialTarifa.SelectedValue = "-1" Then
|
|
Alert("Debe introducir un material.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtTarifa.Text = "" Then
|
|
Alert("Debe introducir una tarifa.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtDistanciaFin.Text = "" Then
|
|
Alert("Debe introducir una distancia fin.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtDistanciaInicio.Text = "" Then
|
|
Alert("Debe introducir una distancia inicio.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtDistanciaInicio.Text.ToDouble > TxtDistanciaFin.Text.ToDouble Then
|
|
Alert("La distancia inicio tiene que ser menor que la distancia fin.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
For Each Gvr As GridViewRow In GvTarifa.Rows
|
|
If ((Gvr.DataKey("DistanciaInicio").ToDouble <= TxtDistanciaInicio.Text.ToDouble And Gvr.DataKey("DistanciaFin").ToDouble >= TxtDistanciaInicio.Text.ToDouble) Or (Gvr.DataKey("DistanciaInicio").ToDouble <= TxtDistanciaFin.Text.ToDouble And Gvr.DataKey("DistanciaFin").ToDouble >= TxtDistanciaFin.Text.ToDouble) Or (Gvr.DataKey("DistanciaInicio").ToDouble >= TxtDistanciaInicio.Text.ToDouble And Gvr.DataKey("DistanciaFin").ToDouble <= TxtDistanciaFin.Text.ToDouble)) And (Gvr.RowIndex <> CveTarifa And DdlMaterialTarifa.SelectedValue = Gvr.DataKey("CveMaterial")) Then
|
|
Alert("El rango que desea agregar en este material esta dentro de los limites de otro.", TipoMensaje.MsgAdvertencia)
|
|
ErrorAgregar = True
|
|
End If
|
|
Next
|
|
If ErrorAgregar = False Then
|
|
If HdnModalidadTarifa.Value = "U" Then
|
|
DTTarifa.AcceptChanges()
|
|
DTTarifa.Rows(CveTarifa).Delete()
|
|
DTTarifa.AcceptChanges()
|
|
End If
|
|
Dim Row As DataRow = Nothing
|
|
Row = DTTarifa.NewRow
|
|
Row("CveTransportista") = DdlTransportista.SelectedValue.ToEntero
|
|
Row("Transportista") = DdlTransportista.SelectedItem.Text
|
|
Row("CveMaterial") = DdlMaterialTarifa.SelectedValue.ToEntero
|
|
Row("Material") = DdlMaterialTarifa.SelectedItem.Text
|
|
Row("Tarifa") = TxtTarifa.Text
|
|
Row("DistanciaInicio") = TxtDistanciaInicio.Text
|
|
Row("DistanciaFin") = TxtDistanciaFin.Text
|
|
DTTarifa.Rows.Add(Row)
|
|
GvTarifa.DataSource = DTTarifa
|
|
GvTarifa.DataBind()
|
|
UpTarifas.Update()
|
|
TxtDistanciaFin.Text = ""
|
|
TxtDistanciaInicio.Text = ""
|
|
TxtTarifa.Text = ""
|
|
DdlTransportista.SelectedIndex = -1
|
|
DdlMaterialTarifa.SelectedIndex = -1
|
|
BtnAgregarTarifaModal.Text = "Agregar"
|
|
myModalLabel.InnerText = "Agregar Tarifa"
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddTarifa"))
|
|
UpAddTarifa.Update()
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub EditTarifa_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CveTarifa = GvRow.RowIndex
|
|
HdnModalidadTarifa.Value = "U"
|
|
UpTarifas.Update()
|
|
BtnAgregarTarifaModal.Text = "Actualizar"
|
|
myModalLabel.InnerText = "Actualizar Tarifa"
|
|
TxtDistanciaFin.Text = GvRow.DataKey("DistanciaFin")
|
|
TxtDistanciaInicio.Text = GvRow.DataKey("DistanciaInicio")
|
|
TxtTarifa.Text = GvRow.DataKey("Tarifa")
|
|
DdlMaterialTarifa.SelectedValueExist(GvRow.DataKey("CveMaterial"))
|
|
DdlTransportista.SelectedValueExist(GvRow.DataKey("CveTransportista"))
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTarifa"))
|
|
UpAddTarifa.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarMaterialModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarMaterialModal.Click
|
|
Dim ErrorAgregar As Boolean = False
|
|
If DdlMaterial.SelectedValue = "-1" Then
|
|
Alert("Debe seleccionar un material.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf DdlUnidadMedida.SelectedValue = "-1" Then
|
|
Alert("Debe seleccionar una unidad de medida.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtVolumen.Text = "" Then
|
|
Alert("Debe introducir un volumen.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtPresupuesto.Text = "" Then
|
|
Alert("Debe introducir un presupuesto.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf TxtVolumenTipo.Text = "" Then
|
|
Alert("Debe introducir un tipo de volumen.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
|
|
If HdnModalidadMaterial.Value = "A" Then
|
|
For Each Gvr As GridViewRow In GvMaterialVolumen.Rows
|
|
If Gvr.DataKey("CveMaterial").ToEntero = DdlMaterial.SelectedValue.ToEntero Then
|
|
Alert("No puede haber dos materiales iguales.", TipoMensaje.MsgAdvertencia)
|
|
ErrorAgregar = True
|
|
End If
|
|
Next
|
|
Else
|
|
For Each Gvr As GridViewRow In GvMaterialVolumen.Rows
|
|
If (Gvr.DataKey("CveMaterial").ToEntero = DdlMaterial.SelectedValue.ToEntero And Gvr.RowIndex <> CveMaterial) Then
|
|
Alert("No puede haber dos materiales iguales.", TipoMensaje.MsgAdvertencia)
|
|
ErrorAgregar = True
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If ErrorAgregar = False Then
|
|
If HdnModalidadMaterial.Value = "U" Then
|
|
DTMaterialVolumen.AcceptChanges()
|
|
DTMaterialVolumen.Rows(CveMaterial).Delete()
|
|
DTMaterialVolumen.AcceptChanges()
|
|
End If
|
|
Dim Row As DataRow = Nothing
|
|
Row = DTMaterialVolumen.NewRow
|
|
Row("CveUnidadMedida") = DdlUnidadMedida.SelectedValue.ToEntero
|
|
Row("UnidadMedida") = DdlUnidadMedida.SelectedItem.Text
|
|
Row("CveMaterial") = DdlMaterial.SelectedValue.ToEntero
|
|
Row("Material") = DdlMaterial.SelectedItem.Text
|
|
Row("Volumen") = TxtVolumen.Text
|
|
Row("Presupuesto") = TxtPresupuesto.Text
|
|
Row("VolumenTipo") = TxtVolumenTipo.Text
|
|
DTMaterialVolumen.Rows.Add(Row)
|
|
GvMaterialVolumen.DataSource = DTMaterialVolumen
|
|
GvMaterialVolumen.DataBind()
|
|
UpMaterialVolumen.Update()
|
|
BtnAgregarMaterialModal.Text = "Agregar"
|
|
H1.InnerText = "Agregar Material y Volumen"
|
|
TxtPresupuesto.Text = ""
|
|
TxtVolumen.Text = ""
|
|
TxtVolumenTipo.Text = ""
|
|
DdlMaterial.SelectedIndex = -1
|
|
DdlUnidadMedida.SelectedIndex = -1
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddMaterial"))
|
|
UpAddMaterial.Update()
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub EditMaterial_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CveMaterial = GvRow.RowIndex
|
|
HdnModalidadMaterial.Value = "U"
|
|
UpMaterialVolumen.Update()
|
|
BtnAgregarMaterialModal.Text = "Actualizar"
|
|
H1.InnerText = "Actualizar Material y Volumen"
|
|
TxtVolumen.Text = GvRow.DataKey("Volumen")
|
|
TxtPresupuesto.Text = GvRow.DataKey("Presupuesto")
|
|
TxtVolumenTipo.Text = GvRow.DataKey("VolumenTipo")
|
|
DdlMaterial.SelectedValueExist(GvRow.DataKey("CveMaterial"))
|
|
DdlUnidadMedida.SelectedValueExist(GvRow.DataKey("CveUnidadMedida"))
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddMaterial"))
|
|
UpAddMaterial.Update()
|
|
End Sub
|
|
|
|
Private Sub GvMaterialVolumen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMaterialVolumen.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.FCLiteral("LtlPresupuesto").Text = "$" + FormatNumber(e.Row.FCLiteral("LtlPresupuesto").Text, 2, , , TriState.True)
|
|
e.Row.FCLiteral("LtlVolumen").Text = FormatNumber(e.Row.FCLiteral("LtlVolumen").Text, 2, , , TriState.True)
|
|
e.Row.FCLiteral("LtlVolumenTipo").Text = FormatNumber(e.Row.FCLiteral("LtlVolumenTipo").Text, 2, , , TriState.True)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GvTarifa_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvTarifa.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.FCLiteral("LtlDistanciaInicio").Text = FormatNumber(e.Row.FCLiteral("LtlDistanciaInicio").Text, 2, , , TriState.True)
|
|
e.Row.FCLiteral("LtlDistanciaFin").Text = FormatNumber(e.Row.FCLiteral("LtlDistanciaFin").Text, 2, , , TriState.True)
|
|
e.Row.FCLiteral("LtlTarifa").Text = "$" + FormatNumber(e.Row.FCLiteral("LtlTarifa").Text, 2, , , TriState.True)
|
|
End If
|
|
End Sub
|
|
End Class
|