|
Mostrar Temas
|
Páginas: [1]
|
3
|
Programación / .NET (C#, VB.NET, ASP) / dudas sobre tener 2 instaladores
|
en: 8 Noviembre 2009, 19:32 pm
|
hola a todos, bueno mi consulta es si un proyecto se puede instalar para 2 tipos de vistas , uno para el lector y otro para el operador. siendo el lector ve una parte del sistema y graba en la base de datos... el operador que tendra otra vista, tambien interactua con la misma base de datos pero obiamente distinta las vistas (privilegios).
gracias...
|
|
|
4
|
Programación / .NET (C#, VB.NET, ASP) / Error al capturar impresion de un documento. .net 2005 sql server.
|
en: 5 Noviembre 2009, 18:43 pm
|
hola nuevamente amigos... bueno yo creo q este el codigo que mas problemas me ha dado... y unos de los mas importante que tengo que sacar este codigo captura los datos de los documentos que se van a imprimir. pero me tira un error cuando imprimo un documento es el siguiente no se puede cargar el archivo DLL kernel32.lib no se puede encontrar el modulo especificadobueno ojala me den ideas de que puede ser. he buscado por el error pero nada referente a lo que estoy haciendo... para el form. se necesita 3 textbox 3 botones y 1 timer1 Imports System.Diagnostics.Debug Imports System.Drawing.Printing Imports System.Runtime.InteropServices
Public Class Form3 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub
'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub
'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Command1 As System.Windows.Forms.Button Friend WithEvents Command2 As System.Windows.Forms.Button Friend WithEvents Command3 As System.Windows.Forms.Button Friend WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents TextBox3 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Command1 = New System.Windows.Forms.Button Me.Command2 = New System.Windows.Forms.Button Me.Command3 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.TextBox3 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'Command1 ' Me.Command1.Location = New System.Drawing.Point(352, 24) Me.Command1.Name = "Command1" Me.Command1.Size = New System.Drawing.Size(136, 23) Me.Command1.TabIndex = 0 Me.Command1.Text = "Activar" ' 'Command2 ' Me.Command2.Location = New System.Drawing.Point(360, 112) Me.Command2.Name = "Command2" Me.Command2.Size = New System.Drawing.Size(128, 23) Me.Command2.TabIndex = 1 Me.Command2.Text = "Parar" ' 'Command3 ' Me.Command3.Location = New System.Drawing.Point(360, 224) Me.Command3.Name = "Command3" Me.Command3.Size = New System.Drawing.Size(128, 23) Me.Command3.TabIndex = 2 Me.Command3.Text = "actualizar" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 24) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(320, 80) Me.TextBox1.TabIndex = 3 ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(8, 120) Me.TextBox2.Multiline = True Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(320, 80) Me.TextBox2.TabIndex = 4 ' 'Timer1 ' Me.Timer1.Enabled = True ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(8, 216) Me.TextBox3.Multiline = True Me.TextBox3.Name = "TextBox3" Me.TextBox3.ScrollBars = System.Windows.Forms.ScrollBars.Vertical Me.TextBox3.Size = New System.Drawing.Size(320, 80) Me.TextBox3.TabIndex = 5 ' 'Form3 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(504, 317) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Command3) Me.Controls.Add(Me.Command2) Me.Controls.Add(Me.Command1) Me.Name = "Form3" Me.Text = "Form1" Me.ResumeLayout(False) Me.PerformLayout()
End Sub #End Region
Public Shared Sub main() Dim PrntInfo As New Form1 PrntInfo.ShowDialog() End Sub
Private Sub Command1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Command1.Click 'Enable the timer to start printer status checks. Timer1.Enabled = True Timer1.Start()
'Enable and disable the start and stop buttons. Command1.Enabled = False Command2.Enabled = True Command3.Enabled = True End Sub
Private Sub Command2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Command2.Click 'Disable the timer to stop additional printer checks. Timer1.Enabled = False
'Enable and disable the start and stop buttons. Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True API = Nothing End Sub
Private Sub Command3_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Command3.Click 'Clear the text boxes to display the printer status. TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles MyBase.Load 'Initialize captions for the buttons. Command1.Text = "Empezar" Command2.Text = "Para" Command3.Text = "Actualizar"
'Clear the text boxes to display the printer status. TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = ""
Command1.Enabled = True 'Disable the stop and clear buttons. Command2.Enabled = False Command3.Enabled = False
'Set the timer interval to 500 milliseconds to examine the printer status. Timer1.Enabled = False Timer1.Interval = 500 End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick Dim PrinterStatus As String Dim JobStatus As String Dim ErrorInfo As String
'Clear the text boxes to display the status. TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = ""
'Call the CheckPrinter function. TextBox1.Text = CheckPrinter(PrinterStatus, JobStatus) TextBox2.Text = PrinterStatus TextBox3.Text = JobStatus End Sub
Public Function CheckPrinter(ByRef PrinterStr As String, _ ByRef JobStr As String) As String Dim hPrinter As IntPtr Dim ByteBuf As Long Dim BytesNeeded As Int32 Dim PI2 As New PRINTER_INFO_2 Dim intCount As Long Dim JI2(intCount) As JOB_INFO_2 Dim PrinterInfo() As Byte Dim JobInfo() As Byte Dim result As Long Dim LastError As Long Dim PrinterName As String Dim tempStr As String Dim NumJI2 As Int32 Dim pDefaults As PRINTER_DEFAULTS
'Set a default return value if no errors occur. CheckPrinter = "Printer info retrieved!"
Dim PD As New PrintDocument PrinterName = PD.PrinterSettings.PrinterName
'Set the access security setting that you want. pDefaults.DesiredAccess = PRINTER_ACCESS_USE
'Call the API to obtain a handle to the printer. 'If an error occurs, display the error. result = WINAPI.OpenPrinter(PrinterName, hPrinter, pDefaults) If result = 0 Then
CheckPrinter = "Cannot open printer " & PrinterName & _ ", Error: " & Marshal.GetLastWin32Error() Exit Function End If
'Initialize the BytesNeeded variable. BytesNeeded = 0
'Clear the error object. Err.Clear()
'Determine the buffer size that is required to obtain the printer information. result = WINAPI.GetPrinter(hPrinter, 2, 0&, 0, BytesNeeded) 'Display the error message that you receive when you call the GetPrinter function, 'and then close the printer handle. If Marshal.GetLastWin32Error() <> ERROR_INSUFFICIENT_BUFFER Then CheckPrinter = " > GetPrinter Failed on initial call! <" WINAPI.ClosePrinter(hPrinter) Exit Function End If ReDim PrinterInfo(BytesNeeded) ByteBuf = BytesNeeded
'Call the GetPrinter function to obtain the status. result = WINAPI.GetPrinter(hPrinter, 2, PrinterInfo(0), ByteBuf, _ BytesNeeded)
'Check for any errors. If result = 0 Then 'Get the error. LastError = Marshal.GetLastWin32Error()
'Display the error message, and then close the printer handle. CheckPrinter = "Could not get Printer Status! Error = " _ & LastError WINAPI.ClosePrinter(hPrinter) Exit Function End If
'Copy the contents of the printer status byte array into a 'PRINTER_INFO_2 structure. PI2 = CType(DatatoDeserial(PrinterInfo, GetType(PRINTER_INFO_2), 1), PRINTER_INFO_2) PrinterStr = CheckPrinterStatus(PI2.Status)
'Add the printer name, the driver, and the port to the text box. PrinterStr = PrinterStr & "Printer Name = " & _ GetString(PI2.pPrinterName) & vbCrLf PrinterStr = PrinterStr & "Printer Driver Name = " & _ GetString(PI2.pDriverName) & vbCrLf PrinterStr = PrinterStr & "Printer Port Name = " & _ GetString(PI2.pPortName) & vbCrLf
'Call the API to obtain the buffer size that is required. result = WINAPI.EnumJobs(hPrinter, 0, &HFFFFFFFF, 2, JobInfo, 0, BytesNeeded, NumJI2) If result = 0 Then 'Display the error, and then close the printer handle. LastError = Marshal.GetLastWin32Error() CheckPrinter = " > EnumJobs Failed on initial call! < Error = " _ & LastError WINAPI.ClosePrinter(hPrinter) Exit Function End If
'If no current jobs exist, display the message. If BytesNeeded = 0 Then JobStr = "No Print Jobs!" Else 'Resize the byte array to hold information about the print jobs. ReDim JobInfo(BytesNeeded - 1)
'Call the API to obtain the print job information. result = WINAPI.EnumJobs(hPrinter, 0, &HFFFFFFFF, 2, JobInfo, _ BytesNeeded, BytesNeeded, NumJI2)
'Check for errors. If result = 0 Then 'Display the error, and then close the printer handle. LastError = Marshal.GetLastWin32Error() CheckPrinter = " > EnumJobs Failed on second call! < Error = " _ & LastError WINAPI.ClosePrinter(hPrinter) Exit Function End If ReDim JI2(NumJI2)
'Copy the contents of print job info byte array into a 'JOB_INFO_2 structure. Try For intCount = 0 To NumJI2 - 1 ' Loop through jobs and obtain the job information. Dim test As Object JI2(intCount) = CType(DatatoDeserial(JobInfo, _ GetType(JOB_INFO_2), intCount + 1), JOB_INFO_2)
JobStr = JobStr & "Job ID = " & JI2(intCount).PrinterJobId & _ vbCrLf & "Total Pages = " & JI2(intCount).TotalPages & vbCrLf
tempStr = "" 'Check for a ready state. If JI2(intCount).pStatus = 0& Then ' If pStatus is Null, check Status. If JI2(intCount).pStatus = 0 Then tempStr = tempStr & "Ready! " & vbCrLf Else 'Check for the various print job states. If (JI2(intCount).pStatus And JOB_STATUS_SPOOLING) Then tempStr = tempStr & "Spooling " End If
If (JI2(intCount).pStatus And JOB_STATUS_OFFLINE) Then tempStr = tempStr & "Off line " End If
If (JI2(intCount).pStatus And JOB_STATUS_PAUSED) Then tempStr = tempStr & "Paused " End If
If (JI2(intCount).pStatus And JOB_STATUS_ERROR) Then tempStr = tempStr & "Error " End If
If (JI2(intCount).pStatus And JOB_STATUS_PAPEROUT) Then tempStr = tempStr & "Paper Out " End If
If (JI2(intCount).pStatus And JOB_STATUS_PRINTING) Then tempStr = tempStr & "Printing " End If
If (JI2(intCount).pStatus And JOB_STATUS_USER_INTERVENTION) Then tempStr = tempStr & "User Intervention Needed " End If
If Len(tempStr) = 0 Then tempStr = "Unknown Status of " & JI2(intCount).PrinterStatus End If End If Else
tempStr = Pointer_to_String(JI2(intCount).pStatus) End If
'Report the job status. JobStr = JobStr & tempStr & vbCrLf Next intCount Catch ex As Exception MessageBox.Show(ex.Message) End Try End If 'Close the printer handle. WINAPI.ClosePrinter(hPrinter) End Function
End Class
|
|
|
5
|
Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Problema con Eliminar 1 registro de la base de datos
|
en: 5 Noviembre 2009, 02:08 am
|
bueno mi problema es el siguiente... este codigo que hize funciona 100% pero hay un detalle que no me gusta y no cacho como sacarlo.. tengo una clase persona y lo llamo desde mi frmEliminar . el problema es el siguiente.. yo para eliminar, mi sistema me exige que tenga un txtclave.text y txttipo.text (texbox1) en el formulario. y todos sabemos que para eliminar un registro no es necesario colocar su clave y tipo , basta con el nombre o rut y listo. pero en mi caso si le saco los txtclave.text y txttipo.text no me corre y me tira errores... alguien me puede decir donde esta el detalle para poder sacar de mi formulario los textbox CODIGO DE LA CLASEImports System Imports System.Collections.Generic Imports System.Text Imports System.Data.SqlClient Imports System.Data Imports Auditoria_de_impresion
Public Class clasePersona
Public Sub New(ByVal perNombre As String, ByVal perContraseña As String, ByVal perTipo As Integer) Dim usuNombre As String Dim usuClave As String Dim usuTipo As Integer usuNombre = perNombre usuClave = perContraseña usuTipo = perTipo
End Sub
Dim conexion As String = "Data Source=localhost\SQLExpress;Initial Catalog=BDIMPRESION;database = usuario; trusted_connection = yes;Integrated Security = True; User Instance=True"
Public Function eliminarUsuario(ByVal usuario As String, ByVal clave As String, ByVal tipo As Integer) As Boolean Dim cn As New SqlClient.SqlConnection(conexion) Dim cmd As New SqlClient.SqlCommand("Delete from usuarios Where perNombre = '" & usuario & "' ", cn) Dim valor As Integer Try If cn.State = ConnectionState.Closed Then cn.Open() End If valor = cmd.ExecuteNonQuery() MsgBox("Usuario Eliminado del Sistema ", MsgBoxStyle.Information) Finally cn.Close() End Try Return valor End Function CODIGO DEL FORMPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim clasePersona As clasePersona = New clasePersona(txtEliminar.Text, txtclave.Text, txttipo.Text) clasePersona.eliminarUsuario(txtEliminar.Text, txtclave.Text, txttipo.Text)
'If MsgBox("Desea Eliminar al Usuario", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Eliminar") = MsgBoxResult.Yes Then
' End If End Sub
|
|
|
6
|
Programación / .NET (C#, VB.NET, ASP) / Capturar de un menuBar "Imprimir" con FindWindows Visual .net 2005
|
en: 4 Noviembre 2009, 20:35 pm
|
Hola a todos ojala me puedan ayudar con este codigo... este codigo hace los siguiente : Lo que hace es comparar la palabra "Imprimir" con los menu de los programas ejemplo : office, notepad, blogdenotas, etc. y busca en el menu la palabra imprimir. entonces si yo ingreso al notepad en este caso y voy a archivo --> "Imprimir" el sistema detecta que yo presione del menu la palabre imprimir y me arroja un msgbox ("Se ha abierto la ventana de impresión") ahora con este codigo y al presionar en cualquier menu el "Imprimir" me salen montones de mensajes ( "Se ha abierto la ventana de impresión") pude hacer que por lo menos me tome la palabra imprimir, pero se me vuleve loco con los mensajes... :s para mas datos en las propiedades del Timer1 en "Enabled" puse True. Public Class Form1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Sub Form_Load() Label1.Text = "Esperando a que se habra la ventana de impresión..." Timer1.Enabled = True Timer1.Interval = 200
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If FindWindow(vbNullString, "Imprimir") <> 0 Then MsgBox("Se ha habierto la ventana de impresion") Label1.Text = "Se ha abierto la ventana de impresión" Timer1.Enabled = False End If
End Sub ojala me puedan ayudar
|
|
|
|
|
|
|