open System
open System.Windows.Forms
open System.Data
open System.Data.SqlClient
open System.Drawing
let salaryform=new Form(Text="Binding in DataTable")
salaryform.BackColor<-Color.BlanchedAlmond
let ffont=new Font("Arial", 9.75F,FontStyle.Regular, GraphicsUnit.Point)
let constring = @"Data Source=MCNDESKTOP34;Initial Catalog=Employee;User ID=; Password="
let adap=new SqlDataAdapter("select * from EmployeeSalary",constring)
let dt=new DataTable()
adap.Fill(dt) |>ignore
let datagrid=new DataGridView(Top=20,Left=0,Width=330,Height=200)
datagrid.DataSource<-dt
let Hsalarylbl=new Label(Top=350,Left=0,Width=120)
Hsalarylbl.Text<-"Higest Salary:"
let HigestSalary=new Label(Top=350,Left=140,BorderStyle=BorderStyle.FixedSingle)
let SHsalarylbl=new Label(Top=380,Left=0,Width=120)
SHsalarylbl.Text<-"Second Higest Salary:"
let SecondHigestSalary=new Label(Top=380,Left=140,BorderStyle=BorderStyle.FixedSingle)
let THsalarylbl=new Label(Top=410,Left=0,Width=120)
THsalarylbl.Text<-"Third Higest Salary:"
let ThirdHigestSalary=new Label(Top=410,Left=140,BorderStyle=BorderStyle.FixedSingle)
let Lowestsalarylbl=new Label(Top=440,Left=0,Width=120)
Lowestsalarylbl.Text<-"Lowest Salary:"
let LowestSalary=new Label(Top=440,Left=140,BorderStyle=BorderStyle.FixedSingle)
let findbtn=new Button(Top=290,Left=80)
findbtn.Text<-"Show"
findbtn.BackColor<-Color.Ivory
salaryform.Controls.Add(datagrid)
salaryform.Controls.Add(Hsalarylbl)
salaryform.Controls.Add(SHsalarylbl)
salaryform.Controls.Add(THsalarylbl)
salaryform.Controls.Add(HigestSalary)
salaryform.Controls.Add(Lowestsalarylbl)
salaryform.Controls.Add(SecondHigestSalary)
salaryform.Controls.Add(ThirdHigestSalary)
salaryform.Controls.Add(LowestSalary)
salaryform.Controls.Add(findbtn)
findbtn.Click.Add(fun _->
let con = new SqlConnection(constring)
//open connection
con.Open()
//FOR HIGEST SALARY
let com = new SqlCommand("Hsalary",con)
com.Connection <- con
com.CommandType <- CommandType.StoredProcedure
com.CommandText <- "Hsalary"
HigestSalary.Text<-com.ExecuteScalar().ToString()
//FOR SECOND HIGHEST SALARY
let com = new SqlCommand("SHSalary",con)
com.Connection <- con
com.CommandType <- CommandType.StoredProcedure
com.CommandText <- "SHSalary"
SecondHigestSalary.Text<-com.ExecuteScalar().ToString()
//FOR THIRD HIGHEST SALARY
let com = new SqlCommand("THSalary",con)
com.Connection <- con
com.CommandType <- CommandType.StoredProcedure
com.CommandText <- "THSalary"
ThirdHigestSalary.Text<-com.ExecuteScalar().ToString()
//FOR LOWEST SALARY
let com = new SqlCommand("LWSalary",con)
com.Connection <- con
com.CommandType <- CommandType.StoredProcedure
com.CommandText <- "LWSalary"
LowestSalary.Text<-com.ExecuteScalar().ToString())
Application.Run(salaryform)