open System
open System.Windows.Forms
open System.Data
open System.Data.SqlClient
open System.Drawing
let constring = @"Data Source=MCNDESKTOP34;Initial Catalog=ImageManipulation;User ID=sa; Password=mcn@123"
let con=new SqlConnection(constring)
let dataadpter = new SqlDataAdapter("Select * from ImageData", constring)
let ffont=new Font("Arial", 9.75F,FontStyle.Regular, GraphicsUnit.Point)
let ds = new DataSet()
dataadpter.Fill(ds,"ImageData")|>ignore
let navform = new Form(Text="Bind DataSource Images")
let lblappname=new Label(Text="Technology:",Location=new System.Drawing.Point(0, 10),AutoSize=true)
let lblicon=new Label(Text="Icon:",Location=new System.Drawing.Point(0, 50),AutoSize=true)
let appnamelabel=new Label(Location=new System.Drawing.Point(140,10),BorderStyle=BorderStyle.FixedSingle)
let appicon=new PictureBox(SizeMode=PictureBoxSizeMode.StretchImage,Location=new System.Drawing.Point(140,50))
let bindsrc=new BindingSource()
let bindnav=new BindingNavigator(Dock=DockStyle.None,Top=150,Left=80)
let movefirst=new ToolStripButton(Text="Top")
let moveprev=new ToolStripButton(Text="Prev")
let movenext=new ToolStripButton(Text="Next")
let movelast=new ToolStripButton(Text="Bottom")
let exitbutton=new ToolStripButton(Text="Exit")
bindnav.Items.Add(movefirst)|>ignore
bindnav.Items.Add(moveprev)|>ignore
bindnav.Items.Add(movenext)|>ignore
bindnav.Items.Add(movelast)|>ignore
bindnav.Items.Add(exitbutton)|>ignore
bindnav.MoveFirstItem<-movefirst
bindnav.MoveNextItem<-movenext
bindnav.MovePreviousItem<-moveprev
bindnav.MoveLastItem<-movelast
exitbutton.Click.Add(fun exit->
navform.Close()
con.Close())
bindsrc.DataSource<-ds
bindsrc.DataMember<-"ImageData"
bindnav.BindingSource<-bindsrc
con.Open()
navform.Font<-ffont
navform.Controls.Add(lblappname)
navform.Controls.Add(lblicon)
navform.Controls.Add(appnamelabel)
navform.Controls.Add(appicon)
navform.Controls.Add(bindnav)
appnamelabel.DataBindings.Add(new Binding("Text",bindsrc,"Name"))
appicon.DataBindings.Add(new Binding("Image",bindsrc,"ImageLogo",true))
navform.Show()
Application.Run(navform)