Commit inicial Ventas Productivo
This commit is contained in:
374
OC/RepCotizacionesDetalle.aspx.vb
Normal file
374
OC/RepCotizacionesDetalle.aspx.vb
Normal file
@@ -0,0 +1,374 @@
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class PopOCCotizacionesDetalle
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "Propiedades"
|
||||
|
||||
Friend Property EsNuevo As Boolean
|
||||
Get
|
||||
EsNuevo = DirectCast(ViewState("EsNuevo"), Boolean)
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("EsNuevo") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
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 CveCotizacion As Integer
|
||||
Get
|
||||
CveCotizacion = ViewState("CveCotizacion").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveCotizacion") = 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
|
||||
|
||||
CType(Me.Master, Site).EsPopup = True
|
||||
CType(Me.Master, BaseMasterPage).PopupWidth = 1000
|
||||
If Not Request("CveOrdenCompra") Is Nothing AndAlso Request("CveOrdenCompra").ToString.ToEntero > 0 Then
|
||||
|
||||
CveOrdenCompra = Request("CveOrdenCompra").ToEntero
|
||||
CargaProveedoresClasificaciones()
|
||||
CargaProveedores()
|
||||
CargaMonedas()
|
||||
|
||||
If Request("CveCotizacion") Is Nothing Then
|
||||
EsNuevo = True
|
||||
CveCotizacion = -1
|
||||
CargaOCDetalle(CveOrdenCompra)
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
Else
|
||||
EsNuevo = False
|
||||
GvDC.DataKeyNames = {"CveOrdenCompra", "CvePS", "Cantidad", "CveUnidadMedida", "CveCotizacionDetalle", "CveOrdenCompraDetalle"}
|
||||
CveCotizacion = Request("CveCotizacion").ToEntero
|
||||
CargaCotizacionDetalle(CveCotizacion)
|
||||
End If
|
||||
BtnGuardar.Visible = True
|
||||
BtnEliminar.Visible = True
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#Region " INICIALIZA VALORES - CARGA COMBOS "
|
||||
Protected Sub CargaProveedoresClasificaciones()
|
||||
CboClasificacionProveedor.DataSource = GlobalDTProveedorClasificacion(UsuarioActual.CveEmpresa)
|
||||
CboClasificacionProveedor.DataBind()
|
||||
|
||||
CboClasificacionProveedor.Items.Insert(0, New ListItem("Clasificacion de Proveedor", "-1"))
|
||||
End Sub
|
||||
Protected Sub CboClasificacionProveedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboClasificacionProveedor.SelectedIndexChanged
|
||||
CargaProveedores()
|
||||
End Sub
|
||||
Protected Sub CargaProveedores()
|
||||
CboProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveProveedorClasificacion = {0} OR {0} = -1", CboClasificacionProveedor.SelectedValue))
|
||||
CboProveedores.DataBind()
|
||||
End Sub
|
||||
|
||||
Protected Sub CargaMonedas()
|
||||
ddlMoneda.DataSource = GlobalDTMonedas()
|
||||
ddlMoneda.DataBind()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "C A R G A D A T O S "
|
||||
Private Sub CargaOCDetalle(pCveOrden As Integer)
|
||||
Dim objOC As New ClsOC
|
||||
|
||||
If objOC.GetOrdenesDetalle(pCveOrden) Then
|
||||
DtDetalle = objOC.DtResultados
|
||||
End If
|
||||
|
||||
' GvD.DataKeyNames = {"CveOrdenCompra", "CveOrdenCompraDetalle"}
|
||||
GvDC.DataSource = DtDetalle
|
||||
GvDC.DataBind()
|
||||
|
||||
|
||||
objOC.Dispose()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCotizacionDetalle(pCveCotizacion As Integer)
|
||||
|
||||
Dim objCotizacion As New ClsOC
|
||||
If objCotizacion.GetCotizaciones(-1, pCveCotizacion) Then
|
||||
If objCotizacion.CveUsuario = 0 Then Deshabilitar()
|
||||
|
||||
TxtFolio.Text = objCotizacion.Folio.ToString
|
||||
CboProveedores.SelectedValue = objCotizacion.CveProveedor.ToString
|
||||
TxtFecha.Text = objCotizacion.Fecha.ToShortDateString
|
||||
ddlMoneda.SelectedValue = objCotizacion.CveMoneda.ToString
|
||||
TxtDiasCredito.Text = objCotizacion.DiasCredito.ToString
|
||||
|
||||
If objCotizacion.Adjunto <> "" Then
|
||||
HplArchivo.NavigateUrl = String.Format("/Empresas/{0}/Cotizaciones/{1}", UsuarioActual.CveEmpresa, objCotizacion.Adjunto)
|
||||
HplArchivo.Text = String.Format("<img targer='_blank' src='/Imagenes/{0}.png' border='0' width='18px' alt='Descargar'/>", IO.Path.GetExtension(objCotizacion.Adjunto).Replace("."c, "")) 'ImageUrl = String.Format("/Imagenes/{0}.png", IO.Path.GetExtension(Cot.NombreArchivo).Replace("."c, ""))
|
||||
HplArchivo.Visible = True
|
||||
End If
|
||||
|
||||
If objCotizacion.GetCotizacionesDetalle(pCveCotizacion) Then
|
||||
DtDetalle = objCotizacion.DtResultados
|
||||
GvDC.DataSource = DtDetalle
|
||||
GvDC.DataBind()
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
objCotizacion.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub Deshabilitar()
|
||||
CboClasificacionProveedor.Enabled = False
|
||||
CboProveedores.Enabled = False
|
||||
ddlMoneda.Enabled = False
|
||||
TxtDiasCredito.Enabled = False
|
||||
TxtFecha.Enabled = False
|
||||
TxtFolio.Enabled = False
|
||||
FUArchivo.Enabled = False
|
||||
|
||||
If UsuarioActual.TienePermisoProceso(146) Then
|
||||
GvDC.Enabled = True
|
||||
Else
|
||||
GvDC.Enabled = False
|
||||
End If
|
||||
|
||||
BtnGuardar.Enabled = False
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " GUARDAR "
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
|
||||
Dim objCotizacion As New ClsOC
|
||||
objCotizacion.IniciaTransacSQL()
|
||||
Dim TieneError = False
|
||||
|
||||
|
||||
|
||||
Try
|
||||
If EsNuevo Then
|
||||
If objCotizacion.AddCotizacion(CveOrdenCompra, CboProveedores.SelectedValue.ToEntero, -1, TxtFolio.Text, TxtFecha.Text, IO.Path.GetExtension(FUArchivo.FileName), ddlMoneda.SelectedValue.ToEntero, TxtDiasCredito.Text.ToEntero, UsuarioActual.CveUsuario) Then
|
||||
If FUArchivo.HasFile Then
|
||||
'verificar que exista el directorio
|
||||
If Not System.IO.Directory.Exists(String.Format("{0}/Empresas/{1}/Cotizaciones/", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa)) Then
|
||||
System.IO.Directory.CreateDirectory(String.Format("{0}/Empresas/{1}/Cotizaciones/", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa))
|
||||
End If
|
||||
FUArchivo.SaveAs(String.Format("{0}/Empresas/{1}/Cotizaciones/{2}{3}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, objCotizacion.CveCotizacion, IO.Path.GetExtension(FUArchivo.FileName)))
|
||||
End If
|
||||
For Each dr As GridViewRow In GvDC.Rows
|
||||
TieneError = Not objCotizacion.AddCotizacionDetalle(objCotizacion.CveCotizacion, dr.DataKey("CvePS").ToEntero, dr.FCTextBox("TxtPU").Text.ToDouble, dr.DataKey("Cantidad").ToDouble, dr.DataKey("CveUnidadMedida").ToEntero, dr.FCTextBox("txtCantidadSurtir").Text.ToDouble, If(dr.FCTextBox("txtFechaEntrega").Text.Trim = "" Or dr.FCTextBox("txtFechaEntrega").Text = "__/__/____", "-1", dr.FCTextBox("txtFechaEntrega").Text), dr.FCTextBox("txtObservacion").Text.ToString, dr.DataKey("CveOrdenCompraDetalle").ToString.ToEntero)
|
||||
If TieneError = True Then Exit For
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
|
||||
Dim NombreArchivo As String = ""
|
||||
|
||||
If objCotizacion.UpdateCotizacion(CboProveedores.SelectedValue.ToEntero, -1, TxtFolio.Text, TxtFecha.Text, IO.Path.GetExtension(FUArchivo.FileName), ddlMoneda.SelectedValue.ToEntero, TxtDiasCredito.Text.ToEntero, UsuarioActual.CveUsuario, CveCotizacion) Then
|
||||
|
||||
If FUArchivo.HasFile Then
|
||||
'verificar que exista el directorio
|
||||
If Not System.IO.Directory.Exists(String.Format("{0}/Empresas/{1}/Cotizaciones/", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa)) Then
|
||||
System.IO.Directory.CreateDirectory(String.Format("{0}/Empresas/{1}/Cotizaciones/", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa))
|
||||
End If
|
||||
FUArchivo.SaveAs(String.Format("{0}/Empresas/{1}/Cotizaciones/{2}{3}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, CveCotizacion, IO.Path.GetExtension(FUArchivo.FileName)))
|
||||
NombreArchivo = CveCotizacion & IO.Path.GetExtension(FUArchivo.FileName)
|
||||
End If
|
||||
|
||||
For Each dr As GridViewRow In GvDC.Rows
|
||||
If dr.DataKey("CveCotizacionDetalle").ToEntero > 0 Then
|
||||
TieneError = Not objCotizacion.UpdateCotizacionDetalle(dr.DataKey("CveCotizacionDetalle").ToEntero, dr.FCTextBox("TxtPU").Text.ToDouble, dr.FCTextBox("txtCantidadSurtir").Text.ToDouble, dr.FCTextBox("txtFechaEntrega").Text, dr.FCTextBox("txtObservacion").Text.ToString)
|
||||
Else
|
||||
|
||||
Dim strTemp = dr.DataKey("CveOrdenCompraDetalle").ToString
|
||||
|
||||
If dr.FCTextBox("txtCantidadSurtir").Text.ToString.ToDouble > 0 Then
|
||||
If dr.FCTextBox("TxtPU").Text.ToDouble > 0 Then TieneError = Not objCotizacion.AddCotizacionDetalle(CveCotizacion, dr.DataKey("CvePS").ToEntero, dr.FCTextBox("TxtPU").Text.ToDouble, dr.DataKey("Cantidad").ToDouble, dr.DataKey("CveUnidadMedida").ToEntero, dr.FCTextBox("txtCantidadSurtir").Text.ToString.ToDouble, If(dr.FCTextBox("txtFechaEntrega").Text.Trim = "" Or dr.FCTextBox("txtFechaEntrega").Text = "__/__/____", "-1", dr.FCTextBox("txtFechaEntrega").Text), dr.FCTextBox("txtObservacion").Text.ToString, dr.DataKey("CveOrdenCompraDetalle").ToEntero)
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
If TieneError = True Then Exit For
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
TieneError = True
|
||||
objCotizacion.RollBack()
|
||||
OnError("Se presento un error al guardar la cotización", ex)
|
||||
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
If Not TieneError Then
|
||||
|
||||
objCotizacion.Commit()
|
||||
Alert(If(EsNuevo, "Cotización Guardada.", "Cotización Actualizada."), TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
Try
|
||||
objCotizacion.RollBack()
|
||||
Catch ex As Exception
|
||||
OnError("Error al intetar hace RollBack", ex)
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
objCotizacion.Dispose()
|
||||
RegistraScript("Ir();")
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
|
||||
#Region " ELIMINAR "
|
||||
Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
||||
Dim objCotizacion As New ClsOC
|
||||
Dim TieneError = False
|
||||
|
||||
If Not objCotizacion.RemoveCotizacionDetalle(CveCotizacion) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If Not TieneError Then Alert("Cotización Eliminada.", TipoMensaje.MsgInformacion)
|
||||
|
||||
objCotizacion.Dispose()
|
||||
RegistraScript("Ir();")
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " G V D "
|
||||
Protected Sub GvD_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDC.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
e.Row.FCTextBox("TxtPU").Attributes.Add("onchange", String.Format("$get('{0}').value = FormatNumber(parseFloat(this.value) * parseFloat($get('{1}').value), 2, true, true, true);", e.Row.FCTextBox("TxtImporte").ClientID, e.Row.FCTextBox("TxtCant").ClientID))
|
||||
e.Row.FCCalendarExtender("CEFechaEntrega").StartDate = Date.Now
|
||||
' e.Row.FCTextBox("TxtPU").Attributes.Add("onchange", String.Format("$get('{0}').value = FormatNumber(parseFloat(this.value) * parseFloat($get('{1}').value), 2, true, true, true);", e.Row.FCTextBox("TxtImporte").ClientID, e.Row.FCTextBox("TxtCant").ClientID))
|
||||
|
||||
'Page.ClientScript.RegisterExpandoAttribute(e.Row.FCCustomValidator("CVFechaEntrega").ClientID, "txtCantidadSurtir", e.Row.FCTextBox("txtCantidadSurtir").ClientID, False)
|
||||
'Page.ClientScript.RegisterExpandoAttribute(e.Row.FCCustomValidator("CVPU").ClientID, "txtCantidadSurtirPU", e.Row.FCTextBox("txtCantidadSurtir").ClientID, False)
|
||||
|
||||
'e.Row.FCCustomValidator("CVFechaEntrega").ClientValidationFunction = "javascript:textValidation(source, arguments);return true;" '"if ($get('" + e.Row.FCTextBox("TxtCantidadSurtir").ClientID + "').value == 0) {arguments.IsValid=true;} else {arguments.IsValid=false;}"
|
||||
|
||||
Try
|
||||
Dim CantidadSurtir = e.Row.DBCampo("CantidadSurtir").ToString
|
||||
Dim FechaEntrga = e.Row.DBCampo("CantidadSurtir").ToString
|
||||
Dim Observacion = e.Row.DBCampo("CantidadSurtir").ToString
|
||||
Dim rfvCatiad As RangeValidator = e.Row.FCRangeValidator("RVCantidad")
|
||||
|
||||
If CantidadSurtir.ToEntero = 0 Then
|
||||
rfvCatiad.Visible = False
|
||||
End If
|
||||
|
||||
e.Row.FCTextBox("txtCantidadSurtir").Text = e.Row.DBCampo("CantidadSurtir").ToString
|
||||
e.Row.FCTextBox("TxtFechaEntrega").Text = If(e.Row.DBCampo("FechaEntrega").ToDate.Year = 1, "", e.Row.DBCampo("FechaEntrega").ToDate.ToString("dd/MM/yyyy"))
|
||||
e.Row.FCTextBox("txtObservacion").Text = e.Row.DBCampo("Observacion").ToString
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
e.Row.FCRangeValidator("RVCantidad").MaximumValue = e.Row.DBCampo("Cantidad")
|
||||
e.Row.FCTextBox("TxtPU").Attributes.Add("onkeyup", String.Format("CalculaImporte({0},this,{1})", e.Row.FCTextBox("TxtCantidadSurtir").ClientID, e.Row.FCTextBox("TxtImporte").ClientID))
|
||||
e.Row.FCTextBox("TxtCantidadSurtir").Attributes.Add("onkeyup", String.Format("CalculaImporte(this,{0},{1})", e.Row.FCTextBox("TxtPU").ClientID, e.Row.FCTextBox("TxtImporte").ClientID))
|
||||
|
||||
'SOLO SI ES UNA COTIZACION YA REGISTRADA DESAHABILITAMOS EL ROW CUANDO YA ESTA CARGADO, PERMISO PARA EDITAR
|
||||
If CveCotizacion > 0 Then
|
||||
Dim EsGanadora As String = e.Row.DBCampo("EsGanadora").ToString
|
||||
If (UsuarioActual.TienePermisoProceso(146) AndAlso EsGanadora = "False") Or (UsuarioActual.TienePermisoProceso(146) AndAlso EsGanadora = "") Then
|
||||
e.Row.Enabled = True
|
||||
Else
|
||||
e.Row.Enabled = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim TxtCantidadSurtir As TextBox = e.Row.FCTextBox("TxtCantidadSurtir")
|
||||
Dim txtFechaEntrega As TextBox = e.Row.FCTextBox("txtFechaEntrega")
|
||||
Dim TxtPU As TextBox = e.Row.FCTextBox("TxtPU")
|
||||
Dim TxtObservacion As TextBox = e.Row.FCTextBox("TxtObservacion")
|
||||
|
||||
TxtCantidadSurtir.Attributes.Add("onkeyup", "validacionRow(this,1)")
|
||||
txtFechaEntrega.Attributes.Add("onkeyup", "validacionRow(this,2)")
|
||||
TxtPU.Attributes.Add("onkeyup", "validacionRow(this,1)")
|
||||
TxtObservacion.Attributes.Add("onkeyup", "validacionRow(this,1)")
|
||||
|
||||
Dim ControlesId As String = String.Format("'{0},{1},{2},{3}'", TxtCantidadSurtir.ClientID, txtFechaEntrega.ClientID, TxtPU.ClientID, TxtObservacion.ClientID)
|
||||
e.Row.Attributes.Add("data-controles", ControlesId)
|
||||
|
||||
Dim RFVCantidadSurtir As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVCantidadSurtir")
|
||||
Dim RVCantidad As RangeValidator = e.Row.FCRangeValidator("RVCantidad")
|
||||
'Dim CVPU As CustomValidator = e.Row.FCCustomValidator("CVPU")
|
||||
Dim CVImgFechaEntrega As CompareValidator = e.Row.FCCompareValidator("CVImgFechaEntrega")
|
||||
Dim RFVTxtPU As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVTxtPU")
|
||||
'Dim RFVtxtFechaEntrega As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVtxtFechaEntrega")
|
||||
|
||||
If TxtCantidadSurtir.Text.ToDouble > 0 Or TxtPU.Text.ToDouble > 0 Then
|
||||
RFVTxtPU.Enabled = True
|
||||
RVCantidad.Enabled = True
|
||||
RFVCantidadSurtir.Enabled = True
|
||||
End If
|
||||
|
||||
If GvDC.DataKeyNames.Contains("CveContizacionDetalle") Then
|
||||
If e.Row.DataKey("CveContizacionDetalle").ToString.ToEntero > 0 Then
|
||||
RFVCantidadSurtir.Enabled = True
|
||||
RVCantidad.Enabled = True
|
||||
' CVPU.Enabled = True
|
||||
CVImgFechaEntrega.Enabled = True
|
||||
RFVTxtPU.Enabled = True
|
||||
'RFVtxtFechaEntrega.Enabled = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
'Dim ValidadoresId As String = String.Format("{0},{1},{2},{3}", RFVCantidadSurtir.ClientID, RVCantidad.ClientID, CVImgFechaEntrega.ClientID, RFVTxtPU.ClientID)
|
||||
'e.Row.Attributes.Add("data-validadores", ValidadoresId)
|
||||
|
||||
|
||||
Dim asdasdasd As String = ""
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user