Imports System.Data Imports System.Globalization Partial Class Customers_Default3 Inherits System.Web.UI.Page Dim datevon As DateTime Dim datebis As DateTime Dim Kdnrtext As String Dim Absender As String = "" Dim Empfaenger As String = "" Dim LKWNR As String = "" Dim KDNAFNR As String = "" Dim dt As List(Of VERAG_PROG_ALLGEMEIN.cRechnungsausgang) Dim reNr As String = "-1" Dim provider As CultureInfo = CultureInfo.InvariantCulture Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Me.Page.User.Identity.IsAuthenticated Then FormsAuthentication.RedirectToLoginPage() Else If String.IsNullOrEmpty(Request.QueryString("P1")) = False Then Kdnrtext = Request.QueryString("P1") Else lbl_status.Text = "Dieser Bereich ist nicht gestattet! Ein Fehler ist bei der Validierung der ID aufgetreten! Bitte erneut versuchen!" End If DataBind() tbl_Header_row.TableSection = TableRowSection.TableHeader If (Page.IsPostBack And normaltable.EnableViewState = False) Then Page.MaintainScrollPositionOnPostBack = True normaltable.EnableViewState = True If valreq_pickdate1.IsValid And valreq_pickdate2.IsValid Then datevon = Date.Parse(pickdate1.Text) datebis = Date.Parse(pickdate2.Text) Else Dim erster = New Date(Now().Year, Now().Month, 1) datevon = erster datebis = Date.Parse(Now.ToShortDateString) pickdate1.Text = erster.ToShortDateString() pickdate2.Text = Date.Now.ToShortDateString() End If End If End If End Sub Protected Sub initcells(tr As TableRow, t1 As TableCell, t2 As TableCell, t3 As TableCell, t4 As TableCell, t5 As TableCell, t6 As TableCell, t7 As TableCell, t8 As TableCell, th1 As TableHeaderCell, th2 As TableHeaderCell, th3 As TableHeaderCell, th4 As TableHeaderCell, th5 As TableHeaderCell, th6 As TableHeaderCell, th7 As TableHeaderCell, th8 As TableHeaderCell) Dim white As Drawing.Color = Drawing.Color.White Dim schwarz As Drawing.Color = Drawing.Color.Black Dim darkgrau As Drawing.Color = Drawing.Color.DarkGray Dim veragblue As Drawing.Color = Drawing.Color.FromArgb(4, 51, 129) tr.BackColor = white If String.IsNullOrEmpty(t1.Text) Then t1.BackColor = white t1.ForeColor = schwarz Else t1.BackColor = white t1.ForeColor = veragblue End If If String.IsNullOrEmpty(t2.Text) Then t2.BackColor = white t2.ForeColor = schwarz Else t2.BackColor = white t2.ForeColor = veragblue End If If String.IsNullOrEmpty(t3.Text) Then t3.BackColor = white t3.ForeColor = schwarz Else t3.BackColor = white t3.ForeColor = veragblue End If If String.IsNullOrEmpty(t4.Text) Then t4.BackColor = white t4.ForeColor = schwarz Else t4.BackColor = white t4.ForeColor = veragblue End If If String.IsNullOrEmpty(t5.Text) Then t5.BackColor = white t5.ForeColor = schwarz Else t5.BackColor = white t5.ForeColor = veragblue End If If String.IsNullOrEmpty(t6.Text) Then t6.BackColor = white t6.ForeColor = schwarz Else t6.BackColor = white t6.ForeColor = veragblue End If If String.IsNullOrEmpty(t7.Text) Then t7.BackColor = white t7.ForeColor = schwarz Else t7.BackColor = white t7.ForeColor = veragblue End If If String.IsNullOrEmpty(t8.Text) Then t8.BackColor = white t8.BackColor = schwarz Else t8.BackColor = white t8.ForeColor = veragblue End If th1.Font.Bold = True th2.Font.Bold = True th3.Font.Bold = True th4.Font.Bold = True th5.Font.Bold = True th6.Font.Bold = True th7.Font.Bold = True th8.Font.Bold = True th1.BackColor = veragblue th2.BackColor = veragblue th3.BackColor = veragblue th4.BackColor = veragblue th5.BackColor = veragblue th6.BackColor = veragblue th7.BackColor = veragblue th8.BackColor = veragblue th1.ForeColor = white th2.ForeColor = white th3.ForeColor = white th4.ForeColor = white th5.ForeColor = white th6.ForeColor = white th7.ForeColor = white th8.ForeColor = white End Sub Protected Sub btn_b_Click(sender As Object, e As EventArgs) dt = Nothing If String.IsNullOrEmpty(Request.QueryString("P1")) = False Then Kdnrtext = Request.QueryString("P1") Else lbl_status.Text = "Dieser Bereich ist nicht gestattet! Ein Fehler ist bei der Validierung der ID aufgetreten! Bitte erneut versuchen!" End If If valdaterage_1.IsValid And valdaterange_2.IsValid Then If String.IsNullOrEmpty(Kdnrtext) = False Then If Not String.IsNullOrEmpty(txt_Absender.Text) Then txt_Absender.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_Absender.Enabled = True regex_txt_Absender.Validate() Try If regex_txt_Absender.IsValid = True Then Absender = txt_Absender.Text Else VERAG_VARIABLES.seterrorcount(1) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + ": Error with the Sender" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(2) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + ": Error Sender Validation" End Try End If If String.IsNullOrEmpty(txt_Empfaenger.Text) = False Then txt_Empfaenger.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_Empfaenger.Enabled = True regex_txt_Empfaenger.Validate() Try If regex_txt_Empfaenger.IsValid = True Then Empfaenger = txt_Empfaenger.Text Else VERAG_VARIABLES.seterrorcount(3) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error with the Reciever" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(4) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error Reciever Validation" End Try End If If String.IsNullOrEmpty(txt_KdNrAuftrag.Text) = False Then txt_KdNrAuftrag.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_KdNrAuftrag.Enabled = True regex_txt_KdNrAuftrag.Validate() Try If regex_txt_KdNrAuftrag.IsValid = True Then KDNAFNR = txt_KdNrAuftrag.Text Else VERAG_VARIABLES.seterrorcount(5) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error with the Customer Order number validation" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(11) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error Customer Order number Validation" End Try End If If String.IsNullOrEmpty(txt_LKW.Text) = False Then txt_LKW.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_LKW.Enabled = True regex_txt_LKW.Validate() Try If regex_txt_LKW.IsValid = True Then LKWNR = txt_LKW.Text Else VERAG_VARIABLES.seterrorcount(6) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error at Validation in LKW number plate field" End If Catch Ex As Exception VERAG_VARIABLES.seterrorcount(12) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb() + "Error LKW Number plate Validation" End Try End If If String.IsNullOrEmpty(txt_ReNr.Text) = False Then txt_ReNr.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_ReNr.Enabled = True regex_txt_ReNr.Validate() Try If regex_txt_ReNr.IsValid = True Then reNr = txt_ReNr.Text Else reNr = "-1" VERAG_VARIABLES.seterrorcount(7) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error at the Validation in the invoice number field" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(13) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error invoice number validation" End Try End If If String.IsNullOrEmpty(txt_Absender_M.Text) = False Then txt_Absender_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_Absender_M.Enabled = True regex_txt_Absender_M.Validate() Try If regex_txt_Absender_M.IsValid = True Then Absender = txt_Absender_M.Text Else VERAG_VARIABLES.seterrorcount(1) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + ": Error with the Sender" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(2) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + ": Error Sender Validation" End Try End If If String.IsNullOrEmpty(txt_Empfaenger_M.Text) = False Then txt_Empfaenger_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_Empaenger_M.Enabled = True regex_txt_Empaenger_M.Validate() Try If regex_txt_Empaenger_M.IsValid = True Then Empfaenger = txt_Empfaenger_M.Text Else VERAG_VARIABLES.seterrorcount(3) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error with the Reciever" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(4) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error Reciever Validation" End Try End If If String.IsNullOrEmpty(txt_KdNrAuftrag_M.Text) = False Then txt_KdNrAuftrag_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_KdNrAuftrag_M.Enabled = True regex_txt_KdNrAuftrag_M.Validate() Try If regex_txt_KdNrAuftrag_M.IsValid = True Then KDNAFNR = txt_KdNrAuftrag_M.Text Else VERAG_VARIABLES.seterrorcount(5) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error with the Customer Order number validation" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(11) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error Customer Order number Validation" End Try End If If String.IsNullOrEmpty(txt_LKW_M.Text) = False Then txt_LKW_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_LKW_M.Enabled = True regex_txt_LKW_M.Validate() Try If regex_txt_LKW_M.IsValid = True Then LKWNR = txt_LKW_M.Text Else VERAG_VARIABLES.seterrorcount(6) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error at Validation in LKW number plate field" End If Catch Ex As Exception VERAG_VARIABLES.seterrorcount(12) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb() + "Error LKW Number plate Validation" End Try End If If String.IsNullOrEmpty(txt_ReNr_M.Text) = False Then txt_ReNr_M.ValidateRequestMode = UI.ValidateRequestMode.Enabled regex_txt_ReNr_M.Enabled = True regex_txt_ReNr_M.Validate() Try If regex_txt_ReNr_M.IsValid = True Then reNr = txt_ReNr_M.Text Else reNr = "-1" VERAG_VARIABLES.seterrorcount(7) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error at the Validation in the invoice number field" End If Catch ex As Exception VERAG_VARIABLES.seterrorcount(13) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error invoice number validation" End Try End If If pickdate1.Text = Nothing Or pickdate2.Text = Nothing Then Try Dim erster = New Date(Now().Year, Now.Month, 1) datevon = erster datebis = Date.Parse(Now.ToShortDateString) pickdate1.Text = datevon.ToShortDateString pickdate2.Text = datebis.ToShortDateString Catch ex As Exception VERAG_VARIABLES.seterrorcount(14) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error in date time conversions" End Try Else Try datevon = CDate(pickdate1.Text) datebis = CDate(pickdate2.Text) Catch ex As Exception VERAG_VARIABLES.seterrorcount(14) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error in date time conversions" End Try End If If String.IsNullOrEmpty(Kdnrtext) = False AndAlso String.IsNullOrEmpty(datevon.ToShortDateString) = False AndAlso String.IsNullOrEmpty(datebis.ToShortDateString) = False Then dt = VERAG_PROG_ALLGEMEIN.cRechnungsausgang.GET_LIST_WEB(Integer.Parse(Kdnrtext), datevon, datebis, Integer.Parse(reNr), Absender, Empfaenger, LKWNR, KDNAFNR) ElseIf String.IsNullOrEmpty(Kdnrtext) = False AndAlso String.IsNullOrEmpty(datevon.ToShortDateString) = False AndAlso String.IsNullOrEmpty(datebis.ToShortDateString) = False And reNr = "" Then dt = VERAG_PROG_ALLGEMEIN.cRechnungsausgang.GET_LIST_WEB(Integer.Parse(Kdnrtext), datevon, datebis, Nothing, Absender, Empfaenger, LKWNR, KDNAFNR) valreq_pickdate1.Validate() valreq_pickdate2.Validate() If valreq_pickdate1.IsValid = False AndAlso valreq_pickdate2.IsValid = False Then VERAG_VARIABLES.seterrorcount(15) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error in form validation. Please fill in all fields" End If End If If dt.Count > 0 Then Dim i As Integer = 0 For Each d In dt Dim tr As TableRow = New TableRow Dim Cell As TableCell = New TableCell Dim tbl_Cell_Index As TableCell = New TableCell Dim tbl_Cell_ReNr As TableCell = New TableCell Dim tbl_Cell_Auftragsdat As TableCell = New TableCell Dim tbl_Cell_Absender As TableCell = New TableCell Dim tbl_Cell_Empfaenger As TableCell = New TableCell Dim tbl_Cell_LKWs As TableCell = New TableCell Dim tbl_Cell_KundAuftrNr As TableCell = New TableCell Dim tbl_Cell_Info As TableCell = New TableCell Dim zahl = i + 1 tbl_Cell_Index.ValidateRequestMode = UI.ValidateRequestMode.Enabled tbl_Cell_Index.Text = zahl.ToString tr.Cells.Add(tbl_Cell_Index) tbl_Cell_ReNr.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.RechnungsNr = Nothing Then tbl_Cell_ReNr.Text = String.Empty Else tbl_Cell_ReNr.Text = d.RechnungsNr.ToString End If tr.Cells.Add(tbl_Cell_ReNr) tbl_Cell_LKWs.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.LKW_Kennzeichen = Nothing Then tbl_Cell_LKWs.Text = String.Empty Else tbl_Cell_LKWs.Text = d.LKW_Kennzeichen.ToString End If tr.Cells.Add(tbl_Cell_LKWs) tbl_Cell_Auftragsdat.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.RechnungsDatum = Nothing Then tbl_Cell_Auftragsdat.Text = String.Empty Else tbl_Cell_Auftragsdat.Text = d.RechnungsDatum.ToString End If tr.Cells.Add(tbl_Cell_Auftragsdat) tbl_Cell_KundAuftrNr.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.KdAuftragsNr = Nothing Then tbl_Cell_KundAuftrNr.Text = String.Empty Else tbl_Cell_KundAuftrNr.Text = d.KdAuftragsNr.ToString End If tr.Cells.Add(tbl_Cell_KundAuftrNr) tbl_Cell_Absender.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.AbsenderName_1 = Nothing Then tbl_Cell_Absender.Text = String.Empty Else tbl_Cell_Absender.Text = d.AbsenderName_1.ToString End If tr.Cells.Add(tbl_Cell_Absender) tbl_Cell_Empfaenger.ValidateRequestMode = UI.ValidateRequestMode.Enabled If d.EmpfängerName_1 = Nothing Then tbl_Cell_Empfaenger.Text = String.Empty Else tbl_Cell_Empfaenger.Text = d.EmpfängerName_1.ToString End If tr.Cells.Add(tbl_Cell_Empfaenger) Dim btn As New ImageButton btn.ViewStateMode = ViewStateMode.Enabled btn.CssClass = "btn btn-primary" btn.ImageUrl = "../images/pdficon.gif" btn.Attributes.Add("href", "pdfviewer.aspx?P1=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.FilialenNr).ToString() + "&P2=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.AbfertigungsNr).ToString + "&P3=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.RK_ID).ToString) btn.Attributes.Add("target", "_blank") btn.PostBackUrl = "pdfviewer.aspx?P1=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.FilialenNr).ToString + "&P2=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.AbfertigungsNr).ToString + "&P3=" + VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(d.RK_ID).ToString tbl_Cell_Info.ValidateRequestMode = UI.ValidateRequestMode.Enabled tbl_Cell_Info.Controls.Add(btn) tr.Cells.Add(tbl_Cell_Info) initcells(tr, tbl_Cell_Index, tbl_Cell_ReNr, tbl_Cell_LKWs, tbl_Cell_Auftragsdat, tbl_Cell_KundAuftrNr, tbl_Cell_Absender, tbl_Cell_Empfaenger, tbl_Cell_Info, tbl_HeaderCellIndex, tbl_HeaderCell_ReNr, tbl_HeaderCell_LKWNr, tbl_HeaderCell_Auftragsdatum, tbl_HeaderCell_KundenAuftrNummer, tbl_HeaderCell_Absender, tbl_HeaderCell_Empfaenger, tbl_HeaderCell_Info) normaltable.Rows.Add(tr) i += 1 Next Else Dim tbl_cellNothing = New TableCell() tbl_cellNothing.ColumnSpan = tbl_Header_row.Cells.Count tbl_cellNothing.Style.Add("text-align", "center") Dim tr As New TableRow tr.Style.Add("text-align", "center") tbl_cellNothing.Text = Server.HtmlEncode("Keine Daten gefunden!") tr.Cells.Add(tbl_cellNothing) normaltable.Rows.Add(tr) End If Else VERAG_VARIABLES.seterrorcount(16) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "Error in getting Customer-ID from login" End If Else VERAG_VARIABLES.seterrorcount(8) lbl_status.Text = VERAG_VARIABLES.geterrornumb + "The time chosen is newer then today or older than april 2001. Please correct" End If 'MsgBox("Test") End Sub Protected Sub btn_resetForm_Click(sender As Object, e As EventArgs) dt = Nothing txt_Absender.Text = String.Empty txt_Absender_M.Text = String.Empty txt_Empfaenger.Text = String.Empty txt_Empfaenger_M.Text = String.Empty txt_KdNrAuftrag.Text = String.Empty txt_KdNrAuftrag_M.Text = String.Empty txt_LKW.Text = String.Empty txt_LKW_M.Text = String.Empty txt_ReNr.Text = String.Empty txt_ReNr_M.Text = String.Empty datevon = Date.ParseExact("01." + Date.Now.Month.ToString + "." + Date.Now.Year.ToString, "dd.MM.yyyy", Nothing) datebis = Date.Now pickdate1.Text = datevon.ToString pickdate2.Text = datebis.ToString Kdnrtext = "" Absender = "" Empfaenger = "" LKWNR = "" KDNAFNR = "" reNr = "" 'MsgBox("Reset") End Sub Protected Sub valdaterage_1_ServerValidate(source As Object, args As ServerValidateEventArgs) If Date.Parse(pickdate1.Text) < Date.ParseExact("01.04.2001", "dd.MM.yyyy", provider) Then VERAG_VARIABLES.seterrorcount(9) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "The chosen time " + pickdate1.Text + " is too early" End If End Sub Protected Sub valdaterange_2_ServerValidate(source As Object, args As ServerValidateEventArgs) If Date.Parse(pickdate2.Text) > Date.ParseExact(Date.Now.ToShortDateString, "dd.MM.yyyy", provider) Then VERAG_VARIABLES.seterrorcount(10) lbl_status.ForeColor = Drawing.Color.Red lbl_status.Text = VERAG_VARIABLES.geterrornumb + "The chosen time " + pickdate2.Text + " is too far in the future" End If End Sub End Class