How to load imagae and data from local database and then display it
here i saving the image and data
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.IO.MemoryMappedFiles;
namespace WhatToWathApp
{
public partial class FAddNewFilm : Form
{
OpenFileDialog ofd;
String originalLocation;
DSWTWapp.tblFilmDataTable dtFilm;
DSWTWappTableAdapters.tblFilmTableAdapter taFilm;
public FAddNewFilm()
{
InitializeComponent();
}
public void init()
{
this.ofd = new OpenFileDialog();
dtFilm = new DSWTWapp.tblFilmDataTable();
taFilm = new DSWTWappTableAdapters.tblFilmTableAdapter();
}
private void btnBrows_Click(object sender, EventArgs e)
{
if(ofd.ShowDialog() == DialogResult.OK)
{
pcbImage.Image = Image.FromFile(ofd.FileName);
txtPath.Text = Path.GetFileName(ofd.FileName);
originalLocation = ofd.FileName;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
if(!Directory.Exists("Images/"))
{
Directory.CreateDirectory("Images/");
}
File.Copy(originalLocation, "Images/" + txtPath.Text, true);
int raFilms = taFilm.Insert(txtName.Text, cmbGener.SelectedItem.ToString(), double.Parse(txtYear.Text), rtbDescription.Text, txtPath.Text);
MessageBox.Show(raFilms.ToString());
}
private void btnClear_Click(object sender, EventArgs e)
{
txtName.Text = String.Empty;
txtYear.Text = String.Empty;
txtPath.Text = String.Empty;
pcbImage.InitialImage = null;
rtbDescription.Text = String.Empty;
}
private void btnBack_Click(object sender, EventArgs e)
{
FHomePage fhp = new FHomePage();
fhp.Show();
this.Hide();
}
}
}