Wednesday, April 27, 2011

Prectical Prectise Questions

Q1] Create a database for vehicle service job contains job-master(job-no, vehicle-no, attend(y/n), type of job (accident, service, color), job-description, entrydate, deliverydate). Write a vb.net code which provide facility of DML, navigation and search operation. Provide search facility on vehicle-no and jobtype jointly, Display result in datagridview.


Q2] Create a webpage which display information about a medical shop. The registered user can order medicine online. Provide appropriate constraints to accept user's personal information using form. Also provide facility to order for medicines which provide facility to order multiple medicines and calculate total Bill-amount.


Q3]
a) Write a java code which accept names and age of 10 students. Sort the names of students agewise in ascending order. Display the names of students using thread class at interval of one seconds.
b) Write a java application which display a pentagon containing a circle within the pentagon where the circumference of the circle touches to the edges of the pentagon. Provide separate colors to both the objects. Display your name in center position of the circle.

Tuesday, April 26, 2011

Solution of Report Daywise Weekwise & Itemwise

Imports System.Data.OleDb
Imports System.Data
Public Class Form1
    Dim cn As OleDbConnection
    Dim da As OleDbDataAdapter
    Dim ds As DataSet
   
'Daywise Report
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
        da = New OleDbDataAdapter("SELECT BillDate AS [BillDate By Day], Sum(Rest.TotalBill) AS [Sum Of TotalBill] FROM Rest GROUP BY BillDate", cn)
        ds = New DataSet
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
    End Sub

'Weekwise Report
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'To Find Week      
        Dim sdate As Date = New Date(Today.Year, Today.Month, 1)
        Dim edate As Date = sdate.AddDays(6)
        While (edate.Month = Today.Month)
            cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
            da = New OleDbDataAdapter("SELECT Sum(TotalBill) FROM Rest Group by BillDate Having BillDate >= #" & sdate & "# and BillDate <= #" & edate & "#", cn)
            ds = New DataSet
            da.Fill(ds)
            DataGridView1.Columns.Add("Week", "Week")
            DataGridView1.Columns.Add("Total", "Total Collection")
            If ds.Tables(0).Rows.Count > 0 Then
'Dynamically add rows to gridview               
   DataGridView1.Rows.Add()
   DataGridView1.Rows(i).Cells(0).Value = sdate.ToString & "-" &  edate.ToString
   DataGridView1.Rows(i).Cells(1).Value = ds.Tables(0).Rows   (i).Item(1).ToString
End If
'Find Next Week           
            sdate = sdate.AddDays(7)
            edate = sdate.AddDays(6)
        End While
       
    End Sub

'Itemwise Report
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
        da = New OleDbDataAdapter("SELECT Itemname , Sum(Rest.TotalBill) AS [Sum Of TotalBill] FROM Rest GROUP BY Itemname", cn)
        ds = New DataSet
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
    End Sub
End Class

Prectical Prectise Questions

Q1] Create a database, which maintain student information. The databse must contain personal information regarding students and their academic information. Desing GUI forms which provide facility of insert, update, delete, navigation of records and search specific records based on city and name.

Q2] Create webpages for placement agency. This website accepts biodata of clients, including personal details and educational qualification. Also provide appropriate constraints to check that the email address and phone numbers are valid. Name, address and educational qualification fields are compulsory. Provide appropriate webpage design including required images.

Q3]
a] Write a javacode which accept start and end alphabates in sequance and print from start position till end position providing one second intervals using thread.
b] Create on applet which display name of your city within a triangle which is inside a circle and vertices of triangles are on the circumference of the circle. Provide separate colors to the triangle and circle.

Monday, April 25, 2011

Prectical Prectise Questions

Q1] Create an application which maintain information about the score of students of BCA studying in 1st to 6th sem. Design appropriate databse and store information using GUI forms. List out name of topper from each semester and search top three students based on selected semester. Also display names of failures. Provide insert, update, delete and search facility.

Q2] Create webpage for ice-creame parlour and various products provided by the parlour. The website provide facility to accept orders online. It check validity of product (must be available in list). Total order quantity must be greater than zero. Calculate total bill rate and tax (10% of total amount). Calculate bill amount.

Q3]
a] Write a java code (Application or applet) Which display current time and date. Use thread class to execute the code.
b] Write java application which accept a string and display the string in reverse order by interchanging its odd positioned characters with even positioned characters.

Prectical Prectise Questions

Q1] Create GUI application which perform add, delete, insert, update, search and navigation operation for following database.
Create appropriate tables to maintain information about various items sold by the restaurant. Also maintain information about bills generated for customers.
Generate reports which display week-wise and day-wise bill-collection and item-wise bill collection.

Q2] Create and design website for a restaurant. Display various special offers given by the owners. Also provide online order facility.

Q3]
 a]Create an applet which display rectangle having a circle inside the rectangle.
b] Create an application which accept ten
names. Display the names using thread at an interval
of 2 seconds.

Friday, April 22, 2011

Basic PayPal integration using a HTTP GET request

To add a simple PayPal button to your website you could use some code like this:
 // Variables
string business = "youremail@example.com";
string item_name = "Screwdriver set";
string item_number = "1054b";
decimal amount = 10.99m;

// Build the PayPal url
StringBuilder sb = new StringBuilder();
sb.Append("cmd=_xclick");
sb.Append("&business=" + HttpUtility.UrlEncode(business));
sb.Append("&no_shipping=1");
sb.Append("&currency_code=GBP");
sb.Append("&lc=GB");
sb.Append("&bn=PP-BuyNowBF");
sb.Append("&item_name=" + HttpUtility.UrlEncode(item_name));
sb.Append("&item_number=" + HttpUtility.UrlEncode(item_number));
sb.Append("&amount=" + HttpUtility.UrlEncode(amount.ToString()));

// Redirect to PayPal to make secure payment
Response.Redirect(@"https://www.paypal.com/cgi-bin/webscr?" + sb.ToString());
Depending on the country you are using PayPal in you may have to change the lc and currency_code lines.
Put this in a button click event on your page, customise the variables as required and you're all set!

Thursday, April 14, 2011

Send Email From Your Web Application Using Your Gmail Account

Imports System.Net.Mail

Dim from As String = ""
 'Replace this with your own correct Gmail Address
Dim to1 As String = ""
 'Replace this with the Email Address to whom you want to send the mail
Dim mail As New System.Net.Mail.MailMessage

mail.To.Add(to1)
mail.From = New MailAddress(from, "CAM", System.Text.Encoding.UTF8)
mail.Subject = "This is a test mail"

mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "This is Email Body Text"

mail.BodyEncoding = System.Text.Encoding.UTF8
mail.IsBodyHtml = True

mail.Priority = MailPriority.High

Dim client As SmtpClient = New SmtpClient()
'Add the Creddentials- use your own email id and password

client.Credentials = New System.Net.NetworkCredential(from, "")
 ' Enter password in string
client.Port = 587 ' Gmail works on this port
client.Host = "smtp.gmail.com"
client.EnableSsl = True ' Gmail works on Server Secured Layer

Try     
     client.Send(mail)
      HttpContext.Current.Response.Write("Succeed")
Catch ex As Exception
      HttpContext.Current.Response.Write(ex.Message)
End Try

Tuesday, April 12, 2011

Database Backup/Restore Utility With SQL-DMO Using VB.NET

Introduction to SQL-DMO
SQL-DMO uses the Microsoft® SQL Server™ ODBC driver to connect to and communicate with instances of SQL Server.  SQL-DMO clients require the SQL Server ODBC Driver, version 3.80 or later, which ships with SQL Server 2000.  All required SQL-DMO components are installed as part of an instance of the Microsoft® SQL Server™ server or client. SQL-DMO is implemented in a single dynamic-link library (DLL). We may develop SQL-DMO applications on either a client or a server.

The following are the main declarations of SQL-DMO objects used:

Imports SQLDMO 

Dim oSQLServer As New SQLDMO.SQLServer
Dim WithEvents oBackup As New SQLDMO.Backup
Dim WithEvents oRestore As New SQLDMO.Restore

oSQLServer is used to connect to SQL Server instance, oBackup to work with the backup operation and oRestore to work with the restore operation.  The word WithEvents raises the respective PercentComplete (gives the progress) event of either oBackup or oRestore objects, when either of them is in the process of operation.

The following are the hard-coded constants used as main parameters:

Const _INSTANCE As String = "."
Const _USER As String = "sa"
Const _PWD As String = ""
Const _BACKUPFILE As String = "c:NorthwindBackup.bkp"
Const _DATABASE As String = "Northwind"

_INSTANCE specifies instance name (in this context localhost).  _USER specifies the userid to logon to instance with the respective password specified using _PWD.  The entire backup is taken into an incremental backup file (every backup gets added to an already existing backup, but within that same file) specified using _BACKUPFILE.  The restore process gets the latest backup within the same backup file.  The backup and restore operations work on the database specified with _DATABASE.

The following is the code to work with the Backup process using SQL-DMO:

Private Sub doBackup()
        With oBackup
            '.Devices = "[NorthwindBackup]"
            .Files = _BACKUPFILE
            .Database = _DATABASE
            .BackupSetName = "MyNorthwindBkp"
            .BackupSetDescription = "Backup from VB.NET application"
            oSQLServer.Connect(_INSTANCE, _USER, _PWD)
            .SQLBackup(oSQLServer)
            oSQLServer.DisConnect()
        End With
        MessageBox.Show("Backup Completed Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

I hope the steps are very simple.  Specify the Backup file name, database name, backup set name, and some description. Connect using oSQLServer object; take the backup using the SQLBackup method of
oBackup object by using the connection at oSQLServer object. Similarly, we can have the code for Restore process as follows:

Private Sub doRestore()
        With oRestore
            '.Devices = "[NorthwindBackup]"
            .Files = _BACKUPFILE
            .Database = _DATABASE
            .ReplaceDatabase = True
            oSQLServer.Connect(_INSTANCE, _USER, _PWD)
            .SQLRestore(oSQLServer)
            oSQLServer.DisConnect()
        End With
        MessageBox.Show("Restore Completed Successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

NOTE: Make sure you close the SQL Server Enterprise Manager before operating the Restore process, as it maintains an exclusive connection to the database.  If you drop the existing database and try to restore it, you have no need to close it.

Monday, April 04, 2011

Saturday, April 02, 2011

Code For Shopping Cart


'----------------------------------------------------------------
' Sub UpdateButton_click:
'   Update the quantity of item(s) in the shopping cart and then display the contents 
'     of the cart
' Parameters:
'   [in] sender: not used
'   [in] e: not used
'----------------------------------------------------------------
Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim cartHasItems As Boolean  'Set if the cart contains items
    Dim i As Integer      'loop index
    Dim quantityString as String 'used for conversion checks
    Dim quantity as Integer 'used to set the items updated quanity
    Dim item As DataGridItem    'used to access the individual grid items
    Dim quantityTextBox As TextBox  'used to access the individual TextBoxes
    Dim row As DataRow 'used to access the individual DataRows

    With ShoppingCart(False)
        If Not .IsEmpty Then
            
            If Not Page.IsValid Then 
                Return
            End If
        
            '
            ' Validators have run so we can assume valid input
            '
            
            '
            ' reset the quanities for all the items in cart
            '
            For i = 0 To CartItemsDataGrid.Items.Count - 1
                item = CartItemsDataGrid.Items(i)
                quantityTextBox = CType(Item.FindControl("QuantityTextBox"), TextBox)
                quantityString = quantityTextBox.Text
                quantity = CInt(quantityString)
                row = .OrderItems.Rows(i)
                'update the quantity
                row(1) = quantity
            Next i
            
            .UpdateItems()
            
            cartHasItems = Not .IsEmpty
            If cartHasItems Then
                'Bind the DataGrid to the items
                CartItemsDataGrid.DataSource = CType(.OrderItems.DefaultView, System.Collections.ICollection)
                CartItemsDataGrid.DataBind
            End If                    
        End If
    End With
    
    '
    ' Set visibility of displayed items to correspond to
    '   whether or not we have items in the cart.
    '
    ShoppingCartPanel.Visible = cartHasItems
    CartItemsDataGrid.Visible = cartHasItems
    CheckOutHyperLink.Visible= cartHasItems
    EmptyCartLabel.Visible = Not cartHasItems
End Sub    

'----------------------------------------------------------------
' Sub UpdateItems:
'   Updates the Items in the shopping cart
'----------------------------------------------------------------
Public Sub UpdateItems()
    Dim row As DataRow  'used to access the individual rows in OrderItems
    Dim quantity As Integer
    Dim itemCount As Integer = OrderItems.Rows.Count
    Dim i As Integer = 0
    
    
    Do While ( i < itemCount)
        With OrderItems.Rows(i)
            quantity = CInt(.Item(OrderData.QUANTITY_FIELD))
            if quantity < 1 Then 
                .Delete
                itemCount = itemCount - 1 
            Else
                .Item(OrderData.EXTENDED_FIELD) = New Decimal(quantity  * CType(.Item(OrderData.PRICE_FIELD), Decimal))
                i = i + 1
            End If
        End With
    Loop 
End Sub