Ayuda con VB.net

changa
26 de Febrero del 2010
Ayuda con VB.net
Hola, soy estudiante de Ingeniera Informtica. En estos momentos estoy enfrascado en la modificacin de una web realizada con VB y asp.net El problema es el siguiente, la web esta dedicada a la publicacin de archivos para compartirlos entre usuarios, el sistema funciona bien pero tiene un pequeo error y es cuando defino una fecha para decidir cuando se debe despublicar o publicar el archivo. Me invierte el da y el mes y por consiguiente me da un error a la hora de insertarlo el la base de dados pues si el da es mayor que 12 al cambirmelo por el mes no me lo inserta. Las paginas tienen extensin .aspx y las que ejecutan del lado del servidor .vbno se si estoy en lo correcto pues soy nuevo en el tema este de .net. Esta es una tarea que me dieron para discutir al final de curso para poder continuar. Si alguien pudiera tirarme una mano con esto le estara muy agradecida
No se donde encontrar el cdigo que inserta en la BD, encuentro el de validacin de la fecha y funciona sin problemas. Tal ves se trata de que no conozco mucho del lenguaje y no reconozco la sentencia
Les dejo un pedazo de cdigo de la pagina Post.aspx.vb que a mi entender es la que realiza la ejecucin.
Mi correo es [email protected] si pueden me respondel al correoo sino revisare el foro periodicamente



Imports BLL
Imports BLL.Utils

Public Class DocumentPostPage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents txtLongName As System.Web.UI.WebControls.TextBox
Protected WithEvents lblLongName As System.Web.UI.WebControls.Label
Protected WithEvents lblShortName As System.Web.UI.WebControls.Label
Protected WithEvents lblVersion As System.Web.UI.WebControls.Label
Protected WithEvents lblConfidential As System.Web.UI.WebControls.Label
Protected WithEvents cboConfidential As System.Web.UI.WebControls.DropDownList
Protected WithEvents lblDescription As System.Web.UI.WebControls.Label
Protected WithEvents txtDescription As System.Web.UI.WebControls.TextBox
Protected WithEvents txtRelatedDocuments As System.Web.UI.WebControls.TextBox
Protected WithEvents lblRelatedDocuments As System.Web.UI.WebControls.Label
Protected WithEvents txtTopics As System.Web.UI.WebControls.TextBox
Protected WithEvents lblTopics As System.Web.UI.WebControls.Label
Protected WithEvents txtRelatedProcesses As System.Web.UI.WebControls.TextBox
Protected WithEvents lblRelatedProcesses As System.Web.UI.WebControls.Label
Protected WithEvents lblExpireDate As System.Web.UI.WebControls.Label
Protected WithEvents lblArchive As System.Web.UI.WebControls.Label
Protected WithEvents lblKeywords As System.Web.UI.WebControls.Label
Protected WithEvents txtKeywords As System.Web.UI.WebControls.TextBox
Protected WithEvents txtShortName As System.Web.UI.WebControls.TextBox
Protected WithEvents lblError As System.Web.UI.WebControls.Label
Protected WithEvents lblValidityDate As System.Web.UI.WebControls.Label
Protected WithEvents cboState As System.Web.UI.WebControls.DropDownList
Protected WithEvents lblState As System.Web.UI.WebControls.Label
Protected WithEvents inArchive As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents rfvLongName As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents rfvVersion As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents txtVersion As Infragistics.WebUI.WebDataInput.WebNumericEdit
Protected WithEvents wdcValidityDate As Infragistics.WebUI.WebSchedule.WebDateChooser
Protected WithEvents wdcExpireDate As Infragistics.WebUI.WebSchedule.WebDateChooser
Protected WithEvents btnAccept As System.Web.UI.WebControls.Button

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
'
'
'
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsAutenticated(User) Then
Response.Redirect("../../Auth/Login.aspx")
Else
If Not IsPostBack Then
Dim categoryID As String = ""
Dim isEdit As Boolean
Dim Reference As String = "" 'DocumentID for new version Reference

If TypeOf Context.Handler Is CategoryDefaultPage Then
With CType(Context.Handler, CategoryDefaultPage)
categoryID = .CategoryID()
isEdit = .IsEdit
End With
ElseIf TypeOf Context.Handler Is DocumentDefaultPage Then
With CType(Context.Handler, DocumentDefaultPage)
categoryID = .CategoryID()
Reference = .DocumentID
isEdit = True
End With
End If

If categoryID <> "" Then
Dim access As New CategoryAccess(categoryID)
If Session("USER") Is Nothing Then
Utils.LogOut(Me)
Exit Sub
Else
If access.HasAccess(Session("USER")) >= AccessRights.Write Then
ViewState("VALID") = True

If Reference <> "" Then
With New Document
.Load(Reference)

If .ExpireDate Is Nothing Then
Response.Redirect("Default.aspx?document=" & Reference & "&error=nonexpire")
Else
txtLongName.Text = .LongName
txtLongName.ReadOnly = True

txtShortName.Text = .ShortName
txtShortName.ReadOnly = True

txtVersion.Text = .Version + 0.1

cboConfidential.SelectedValue = .Confidential
txtDescription.Text = .Description
txtTopics.Text = .Topics
txtRelatedDocuments.Text = .RelatedDocuments
txtRelatedProcesses.Text = .RelatedProcesses
txtKeywords.Text = .Keywords
End If
End With
End If


ViewState.Item("CATEGORY") = categoryID
ViewState.Item("EDIT") = isEdit
ViewState.Item("REFERENCE") = Reference

If isEdit Then
'fill document states
Dim states As New DocumentStates
With cboState
.DataTextField = "Name"
.DataValueField = "DocumentStateID"
.DataSource = states.LoadList
.DataBind()
End With
Else
lblState.Visible = False
cboState.Visible = False

wdcValidityDate.Value = Date.Today
wdcValidityDate.ReadOnly = True
End If

wdcValidityDate.MinDate = Date.Today
wdcExpireDate.MinDate = Date.Today
Else
lblError.Text = "Acceso de Edicin Denegado."
ViewState("VALID") = False
End If
End If
Else

lblError.Text = "Parmetro 'category' requerido."
End If
End If
End If
End Sub
'
'
'
Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
If txtLongName.Text <> "" And txtVersion.Value > 0 And inArchive.PostedFile.FileName <> "" Then
If IsNumeric(txtVersion.Value) Then
If ViewState("VALID") = True Then
Dim categoryID As String = ViewState.Item("CATEGORY")

If categoryID <> "" Then
With New Document
If Session("DOMAIN") Is Nothing Then
Utils.LogOut(Me)
Exit Sub
Else
.Domain = Session("DOMAIN")
End If

.Category = ViewState.Item("CATEGORY")

If (Not ViewState.Item("REFERENCE") Is Nothing) And (ViewState.Item("REFERENCE") <> "") Then
.Reference = ViewState.Item("REFERENCE")

Dim reference As New Document
reference.Load(.Reference)

If reference.Version > txtVersion.Value Then
lblError.Text = "Nmero de Versin incorrecta."
Exit Sub
End If
End If

.LongName = txtLongName.Text
.ShortName = txtShortName.Text
.Version = txtVersion.Value
.Confidential = cboConfidential.SelectedValue
.Description = txtDescription.Text
.Topics = txtTopics.Text
.RelatedDocuments = txtRelatedDocuments.Text
.RelatedProcesses = txtRelatedProcesses.Text

If ViewState.Item("EDIT") = True Then
If Not wdcValidityDate.Value Is Nothing Then
If wdcValidityDate.Value >= Date.Today Then
.ValidityDate = CType(wdcValidityDate.Value, DateTime).ToString("MM/dd/yyyy")
Else
lblError.Text = "Fecha de Entrada en Vigencia incorrecta."
Exit Sub
End If
End If
Else
'
'
'

.ValidityDate = CType(Date.Now, DateTime).ToString("MM/dd/yyyy")
End If

If Not (wdcExpireDate.Value Is Nothing) Then
If wdcExpireDate.Value > Date.Today Then
.ExpireDate = CType(wdcExpireDate.Value, DateTime).ToString("MM/dd/yyyy")
Else
lblError.Text = "Fecha de Expiracin incorrecta."
Exit Sub
End If
End If

If (Not (wdcValidityDate.Value Is Nothing)) And (Not (wdcExpireDate.Value Is Nothing)) Then
If (wdcExpireDate.Value < wdcValidityDate.Value) Then
lblError.Text = "Fecha de Expiracin incorrecta."
Exit Sub
End If
End If

If ViewState.Item("EDIT") = True Then
.State = cboState.SelectedValue
Else
.State = 4 'Ready
End If

'Archive
Dim fileName As String = Guid.NewGuid.ToString & "-" & System.IO.Path.GetFileName(inArchive.PostedFile.FileName)
Dim filePath As String = ConfigurationSettings.AppSettings("archivesPath")

Try
.Archive = fileName
inArchive.PostedFile.SaveAs(filePath & fileName)
Catch exp As Exception
lblError.Text = "Fall publicacin del Archivo Relacionado."
Exit Sub
End Try

If Session("USER") Is Nothing Then
Utils.LogOut(Me)
Exit Sub
Else
.Owner = Session("USER")
End If

.Keywords = txtKeywords.Text

Dim newDocumentID As Integer
newDocumentID = .Insert()

'set full document access to Owner
With New DocumentAccess(newDocumentID)
.User = Session("USER")
.Right = AccessRights.Full
.Insert()
End With
End With

If ViewState.Item("EDIT") = True Then
Response.Redirect("../BrowseCategory/Default.aspx?edit=1&category=" & ViewState.Item("CATEGORY"))
Else

Response.Redirect("../BrowseCategory/Default.aspx?category=" & ViewState.Item("CATEGORY"))
End If
Else
lblError.Text = "Parmetro 'category' requerido."
End If
Else
lblError.Text = "Acceso de Publicacin Denegado."
End If
Else
lblError.Text = "Versin debe ser un valor numrico."
End If
Else
lblError.Text = "Nombre Largo, Versin, Archivo Relacionado requeridos."
End If
End Sub
'
'
'
End Class