Click here to Skip to main content
15,949,741 members

Comments by Member 10496260 (Top 6 by date)

Member 10496260 5-Jan-15 7:34am View    
I know its not type of computing but if we think then it will be..?
Sir, If you have any idea related to this then please let me know.
Member 10496260 20-Feb-14 3:23am View    
sorry for late
here is the code which i used for printing ...i am creating image of data and also uses panel for datagridview as datagridview row increases i am increasing the panel size also but its still giving problem ....



Public Class posbill
Private Sub data()

Try
If dgw1.Columns.Count = 0 Then
For Each dgvc As DataGridViewColumn In bill.dgw.Columns
dgw1.Columns.Add(TryCast(dgvc.Clone(), DataGridViewColumn))
Next
End If

Dim row As New DataGridViewRow()

For i As Integer = 0 To bill.dgw.Rows.Count - 1
row = DirectCast(bill.dgw.Rows(i).Clone(), DataGridViewRow)
Dim intColIndex As Integer = 0
For Each cell As DataGridViewCell In bill.dgw.Rows(i).Cells
row.Cells(intColIndex).Value = cell.Value
intColIndex += 1
Next
dgw1.Rows.Add(row)
Next
dgw1.AllowUserToAddRows = False

dgw1.Refresh()
Catch ex As Exception

End Try


End Sub

Private Sub possbill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dgw1.Rows.Clear()

data()
'LoadReceipt()

lblinvooiceno.Text = bill.lblInvoiceNo.Text
lbldate.Text = bill.lbldate.Text
lbltotalcost.Text = bill.lblTotalCost.Text
lblcontactno.Text = bill.txtcntctno.Text
lblcustomerno.Text = bill.txtcustname.Text
lblRemaining.Text = bill.txtremaining.Text
PrintDialog1.Document = Me.PrintDocument1
Try
Dim ButtonPressed As DialogResult = PrintDialog1.ShowDialog()
If (ButtonPressed = DialogResult.OK) Then
PrintDocument1.Print()
End If
'Me.Close()

Catch ex As Exception


MsgBox(ex.Message)

End Try

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(Me.Panel2.Width, Me.Panel2.Height)

Panel2.DrawToBitmap(bm, New Rectangle(0, 0, Me.Panel2.Width, Me.Panel2.Height))

e.Graphics.DrawImage(bm, 0, 0)
Dim aPS As New PageSetupDialog
aPS.Document = PrintDocument1
End Sub
Private Sub LoadReceipt()
Dim x As Integer = 0
Dim Y As Integer = 0
Try
sqL = "SELECT iDescription,UnitPrice,Quantity FROM Item as P, POSDetail as TD, POS as T WHERE TD.InvoiceNo = T.InvoiceNo AND T.InvoiceNo = '" & bill.lblInvoiceNo.Text & "' ORDER By ItemNo"
ConnDB()
cmd = New OleDbCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dgw1.Rows.Clear()

Do While dr.Read = True
dgw1.Rows.Add(dr("iDescription"), dr("UnitPrice"), dr("Quantity"))

dgw1.Height += 19
x += 19
Loop
Y = x - 30
dgw1.Height = dgw1.Height - 20

Panel2.Height = Panel2.Height + Y
Me.Height = Me.Height + Y
Me.Panel3.Location = New Point(9, 542 + Y)
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)

End Sub
End Class
Member 10496260 20-Jan-14 8:08am View    
Public Class clsSMS

#Region "Open and Close Ports"
'Open Port
Public Function OpenPort(ByVal p_strPortName As String, ByVal p_uBaudRate As Integer, ByVal p_uDataBits As Integer, ByVal p_uReadTimeout As Integer, ByVal p_uWriteTimeout As Integer) As SerialPort
receiveNow = New AutoResetEvent(False)
Dim port As New SerialPort()

Try
port.PortName = p_strPortName 'COM1
port.BaudRate = p_uBaudRate '9600
port.DataBits = p_uDataBits '8
port.StopBits = StopBits.One '1
port.Parity = Parity.None 'None
port.ReadTimeout = p_uReadTimeout '300
port.WriteTimeout = p_uWriteTimeout '300
port.Encoding = Encoding.GetEncoding("iso-8859-1")
AddHandler port.DataReceived, AddressOf port_DataReceived
port.Open()
port.DtrEnable = True
port.RtsEnable = True
Catch ex As Exception
Throw ex
End Try
Return port
End Function

'Close Port
Public Sub ClosePort(ByVal port As SerialPort)
Try
port.Close()
RemoveHandler port.DataReceived, AddressOf port_DataReceived
port = Nothing
Catch ex As Exception
Throw ex
End Try
End Sub

#End Region

'Execute AT Command
Public Function ExecCommand(ByVal port As SerialPort, ByVal command As String, ByVal responseTimeout As Integer, ByVal errorMessage As String) As String
Try

port.DiscardOutBuffer()
port.DiscardInBuffer()
receiveNow.Reset()
port.Write(command & vbCr)

Dim input As String = ReadResponse(port, responseTimeout)
If (input.Length = 0) OrElse (((Not input.EndsWith(vbCrLf & "> "))) AndAlso ((Not input.EndsWith(vbCrLf & "OK" & vbCrLf)))) Then
Throw New ApplicationException("No success message was received.")
End If
Return input
Catch ex As Exception
Throw ex
End Try
End Function

'Receive data from port
Public Sub port_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
Try
If e.EventType = SerialData.Chars Then
receiveNow.Set()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Public Function ReadResponse(ByVal port As SerialPort, ByVal timeout As Integer) As String
Dim buffer As String = String.Empty
Try
Do
If receiveNow.WaitOne(timeout, False) Then
Dim t As String = port.ReadExisting()
buffer &= t
Else
If buffer.Length > 0 Then
Throw New ApplicationException("Response received is incomplete.")
Else
Throw New ApplicationException("No data received from phone.")
End If
End If
Loop While (Not buffer.EndsWith(vbCrLf & "OK" & vbCrLf)) AndAlso (Not buffer.EndsWith(vbCrLf & "> ")) AndAlso Not buffer.EndsWith(vbCrLf & "ERROR" & vbCrLf)
Catch ex As Exception
Throw ex
End Try
Return buffer
End Function

#Region "Count SMS"
Public Function CountSMSmessages(ByVal port As SerialPort) As Integer
Dim CountTotalMessages As Integer = 0
Try

' #Region "Execute Command"

Dim recievedData As String = ExecCommand(port, "AT", 300, "No phone connected at ")
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.")
Dim command As String = "AT+CPMS?"
recievedData = ExecCommand(port, command, 1000, "Failed to count SMS message")
Dim uReceivedDataLength As Integer = recievedData.Length

' #End Region

' #Region "If command is executed successfully"
If (recievedData.Length >= 45) AndAlso (recievedData.StartsWith("AT+CPMS?")) Then

' #Region "Parsing SMS"
Dim strSplit() As String = recievedData.Split(","c)
Dim strMessageStorageArea1 As String = strSplit(0) 'SM
Dim strMessageExist1 As String = strSplit(1) 'Msgs exist in SM
' #End Region

' #Region "Count Total Number of SMS In SIM"
CountTotalMessages = Convert.ToInt32(strMessageExist1)
' #End Region

' #End Region

' #Region "If command is not executed successfully"
ElseIf recievedData.Contains("ERROR") Then

' #Region "Error in Counting total number of SMS"
Member 10496260 20-Jan-14 7:57am View    
at the time of sending message ,when i clicked on send button then it waits for some time and gives me "write time out error "(there is by default write time out error 300)i changes to it also but same error occurs
Member 10496260 20-Jan-14 7:46am View    
i got code from this link
http://www.codeproject.com/Articles/38705/Send-and-Read-SMS-through-a-GSM-Modem-using-AT-Com?fid=1544794&select=4721864&tid=4721864