Imports System.Data Imports Extensiones Partial Class PopOCCotizaciones Inherits ClsPaginas #Region "Propiedades" Private Property CveOrdenCompra As Integer Get CveOrdenCompra = ViewState("CveOrdenCompra").ToString.ToEntero End Get Set(value As Integer) ViewState("CveOrdenCompra") = value End Set End Property Private Property DtDetalle As DataTable Get DtDetalle = DirectCast(ViewState("DtDetalle"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDetalle") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then If Not Request("OC") Is Nothing AndAlso Request("OC").ToString.ToEntero > 0 Then Master.EsPopup = True CveOrdenCompra = Request("OC").ToEntero CargaCotizaciones(CveOrdenCompra) CboProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) CboProveedores.DataBind() End If End If End Sub Private Sub CargaCotizaciones(CveOrden As Integer) Dim Cotizaciones As New ClsOC If Cotizaciones.GetCotizaciones(CveOrden) Then DtDetalle = Cotizaciones.DtResultados GVC.DataSource = DtDetalle GVC.DataBind() End If Cotizaciones.Dispose() End Sub Protected Sub ImgAddFactura_Click(sender As Object, e As ImageClickEventArgs) Handles ImgAddFactura.Click If FUArchivo.HasFile Then Dim Cotizaciones As New ClsOC Dim CveCotizacion As Integer = Cotizaciones.AddCotizacion(TxtDescripcion.Text, CveOrdenCompra, CboProveedores.SelectedValue.ToEntero, 0, TxtTotal.Text.ToDouble, TxtFecha.Text.ToDate, IO.Path.GetExtension(FUArchivo.FileName), UsuarioActual.CveUsuario) If CveCotizacion > 0 Then FUArchivo.SaveAs(String.Format("{0}/OC/Cotizaciones/{1}{2}", AppDomain.CurrentDomain.BaseDirectory, CveCotizacion, IO.Path.GetExtension(FUArchivo.FileName))) GVC.DataSource = Cotizaciones.DtResultados GVC.DataBind() End If Cotizaciones.Dispose() Else Alert("No se pudo cargar el archivo") End If End Sub Protected Sub GVC_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GVC.RowCommand If e.CommandName = "Eliminar" Then Dim Cotizaciones As New ClsOC Dim NombreArchivo As String = Cotizaciones.RemoveCotizacion(e.CommandArgument.ToString.ToEntero) If NombreArchivo <> "" Then If IO.File.Exists("~/OC/Cotizaciones/" & NombreArchivo) Then IO.File.Exists("~/OC/Cotizaciones/" & NombreArchivo) End If GVC.DataSource = Cotizaciones.DtResultados GVC.DataBind() End If Cotizaciones.Dispose() End If End Sub End Class