My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Friday, 6 July 2018
insert data using Entity Framewrok database 1st Approach in windows from
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 WindowsFormsApplication9.Model;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
db1708c1Entities db = new db1708c1Entities();
tbl_student s = new tbl_student();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
s.name = textBox1.Text;
s.dob = dateTimePicker1.Value;
s.contatct = textBox2.Text;
if (s.C_image==null)
{
s.C_image = @"C:\images\unknown.png";
}
db.tbl_student.Add(s);
db.SaveChanges();
MessageBox.Show("Data successfully inserted......");
dataGridView1.DataSource = db.tbl_student.ToList();
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = db.tbl_student.ToList();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
op.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (op.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(op.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
s.C_image = op.FileName;
}
}
}
}
Subscribe to:
Posts (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...