Saturday, 24 November 2012

VB.NET Form Design with code


MODULE CODE

Imports System.Data.OleDb
Module Module1
    Public Cn As New OleDbConnection("Provider=MSDAORA.1;user id=scott;password=tiger")
    Public Fdt As String, Tdt As String, Opt As String, Cont As Int16, Agn As Int16

    Public Sub ConnectDB()
        If Cn.State = ConnectionState.Closed Then Cn.Open()
    End Sub

    Public Function Gen_PK(ByVal Fld As String, ByVal Tbl As String) As Integer
        ConnectDB()
        Dim Cmd As New OleDbCommand("Select Max(" & Fld & ") from " & Tbl)
        Cmd.Connection = Cn

        If Not IsDBNull(Cmd.ExecuteScalar) Then
            Return Cmd.ExecuteScalar + 1
        Else
            Return 1
        End If
        Cmd.Dispose()
    End Function
End Module


STAFF FORM CODE

Imports System.Data.OleDb
Public Class Staff

Private Sub Staff_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DataSet1.KSTAFF' table. You can move, or remove it, as needed.
        Me.KSTAFFTableAdapter.Fill(Me.DataSet1.KSTAFF)
        Btnenb()
        LckCnt()
    End Sub

    Private Sub Btnenb()
        BtnA.Enabled = True
        BtnS.Enabled = False
        BtnE.Enabled = True
        BtnC.Enabled = False
        BtnEX.Enabled = True
    End Sub

    Private Sub Btndenb()
        BtnA.Enabled = False
        BtnS.Enabled = True
        BtnE.Enabled = False
        BtnC.Enabled = True
        BtnEX.Enabled = False
    End Sub

    Private Sub LckCnt()
        Dim obj As Control
        For Each obj In GroupBox1.Controls
            If TypeOf obj Is TextBox Then
                obj.Enabled = False
                obj.Text = ""
            End If
        Next
    End Sub
    Private Sub UnLckCnt()
        Dim obj As Control
        For Each obj In GroupBox1.Controls
            If TypeOf obj Is TextBox Then
                obj.Enabled = True
            End If
        Next
    End Sub

Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DTP2.ValueChanged
    End Sub

Private Sub BtnA_Click(ByVal sender As System.Object, ByVal e As    System.EventArgs) Handles BtnA.Click
        Btndenb()
        UnLckCnt()
        TxtSlno.Text = Module1.Gen_PK("SNO", "kstaff")
        TxtFname.Focus()
End Sub

Private Sub BtnS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnS.Click
Dim cmd As New OleDbCommand
ConnectDB()
cmd.Connection = Cn
If BtnS.Text = "Save" Then
cmd.CommandText = "insert into KSTAFF values(" & TxtSlno.Text & " ,'" & TxtFname.Text & "','" & TxtMname.Text & "','" & TxtLname.Text & "','" & TxtAddr.Text & "','" & DTP1.Text & "','" & TxtCity.Text & "'," & TxtPcode.Text & " ," & TxtMob.Text & ",'" & DTP2.Text & "','" & CmbDes.Text & "','" & CmbDept.Text & "')"
cmd.ExecuteNonQuery()
MsgBox("Record Saved")
ElseIf BtnS.Text = "Update" Then
cmd.CommandText = " update kstaff set FNAME ='" & TxtFname.Text & "',MNAME ='" & TxtMname.Text & "', LNAME ='" & TxtLname.Text & "',ADDR ='" & TxtAddr.Text & "', DOB ='" & DTP1.Text & "',CITY ='" & TxtCity.Text & "',PCODE =" & TxtPcode.Text & " , MOB =" & TxtMob.Text & " , DOJ ='" & DTP2.Text & "', DES ='" & CmbDes.Text & "', DEPT ='" & CmbDept.Text & "' where SNO = " & TxtSlno.Text
cmd.ExecuteNonQuery()
MsgBox("Record Modified", MsgBoxStyle.Information, "Setup")
End If
DataSet1.Clear()
Me.KSTAFFTableAdapter.Fill(Me.DataSet1.KSTAFF)
Btnenb()
LckCnt()
BtnS.Text = "Save"
End Sub

Private Sub BtnE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnE.Click
If TxtSlno.Text = "" Then
MsgBox("Select Record to Modify", MsgBoxStyle.Critical, "Setup")
Exit Sub
End If
Btndenb()
UnLckCnt()
BtnS.Text = "Update"
End Sub

Private Sub BtnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnC.Click
Dim r As String
r = MsgBox("Do you want to cancel", MsgBoxStyle.YesNo, "Warning")
If r = vbYes Then
Me.Close()
Else
TxtFname.Focus()
End If
End Sub


Private Sub BtnEX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEX.Click
Me.Close()
End Sub

   

  
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
        TxtSlno.Text = DataGridView1.SelectedCells(0).Value
        TxtFname.Text = DataGridView1.SelectedCells(1).Value
        TxtMname.Text = DataGridView1.SelectedCells(2).Value
        TxtLname.Text = DataGridView1.SelectedCells(3).Value
        TxtAddr.Text = DataGridView1.SelectedCells(4).Value
        DTP1.Text = DataGridView1.SelectedCells(5).Value
        TxtCity.Text = DataGridView1.SelectedCells(6).Value
        TxtPcode.Text = DataGridView1.SelectedCells(7).Value
        TxtMob.Text = DataGridView1.SelectedCells(8).Value
        DTP2.Text = DataGridView1.SelectedCells(9).Value
        CmbDes.Text = DataGridView1.SelectedCells(10).Value
        CmbDept.Text = DataGridView1.SelectedCells(11).Value
End Sub

  
End Class



Sunday, 29 July 2012

TRICKS

Put ur name with time and show the name as time zone
this tricks works with windows xp only.
to do this just follow these steps . . .

GO TO "CONTROL PANEL"

THE GO TO


regional and language option >> customize >> time or date option >> time symbol

now change it with ur name . . .






SEND APPLICATION OR .EXE FILE VIA GMAIL

"OPEN MICROSOFT WORD AND PASTE YOUR FILE IN DOCUMENT"



IT WILL SHOW NO ERROR OR NO DISCARDING MSG . . . and send

Virus in Notepad


Shut down your friend computer:
Type in notepad:

@echo off
msg * I don't like you
shutdown -c "Error! You are too silly!" -s


Save it as "<filename>.bat". and run it

Friday, 6 January 2012

GRANT,REVOKE previleges for the USER in Oracle -xe

Creating Use AND PROVIDING PREVILEGES:


SQL>connect system/<passward>


SQL>CREATE USER <user name> IDENTIFIED BY <USER_passward>;


SQL>ALTER USER <user name> ACCOUNT UNLOCK;


SQL>GRANT CONNECT TO <user name>;


SQL>GRANT RESOURCE TO <user name>;


SQL>GRANT CREATE VIEW TO <user name>;


SQL>GRANT CREATE TRIGGER TO <user name>;


                                  OR


SQL>GRANT DBA TO <user name>;

Install ORACLE 10G Express Edition in LINUX OS

 To install Oracle-xe:


mount the software in download folder >> right click and open with Gdebi package installer


>>close the window >>Open New terminal and type the following:


sudo /etc/init.d/oracle-xe <space> configure <enter>


provide passward for system.


Now oracle-xe is installed.

Tuesday, 19 July 2011

LOCK THE FOLDER

Note :If you are familiar with DOS commands,then only try this.

1. Gather all the files that you wish to hide in a folder anywhere in your PC (make it in C:\hidden – RECOMMENDED).

2. Now, add those files in a RAR archive (e.g. secret.rar). This file should also be in the same directory (C:\hidden).

3. Now, look for a simple JPEG picture file (e.g. logo.jpg). Copy/Paste that file also in C:\hidden.

4. Now, open Command Prompt (Go to Run and type ‘cmd‘). Make your workingdirectory C:\hidden.

5. Now type: “COPY /b logo.jpg + secret.rar output.jpg” (without quotes) – Now, logo.jpg is the picture you want to show, secret.rar is the file to be hidden, and output.jpg is the file which contains both.

6. Now, after you have done this, you will see a file output.jpg in C:\hidden. Open it(double-click) and it will show the picture you wanted to show. Now try opening the same file with WinRAR, it will show the hidden archive .

Monday, 18 July 2011

PROGRAM TO OBTAIN ADDRESSES OF PRINTER PORTS

//PROGRAM TO OBTAIN ADDRESSES OF PRINTER PORTS 
#include <stdio.h>
#include <dos.h>

void main(void)
{
      unsigned int far *ptraddr;  /* Pointer to location of Port Addresses */
      unsigned int address;  /* Address of Port */
      int i;

      ptraddr=(unsigned int far *)0x00000408;

      for (i = 0; i < 3; i++)
      {
               address = *ptraddr;
               if (address == 0)
               printf ("No port found for LPT%d \n", i+1);
               else
               printf("Address assigned to LPT%d is %Xh\n", i+1,address);
              *ptraddr++;
       }
}

Note :Execute this code on your own risk.

Get CSV Values in SQL

Query: DECLARE @CSVValue NVARCHAR(50)='100,101,102'                   DECLARE @eachValue NUMERIC(9,0)   while len(@CSVValue) ...