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;
namespace GalleryProject1
{
public partial class custWin : Form
{
dbEntities db = new dbEntities();
public custWin()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
orderTBL o1 = new orderTBL();
customerTBL c1 = (customerTBL)comboBox1.SelectedItem;
o1.custID = c1.Id;
o1.date = dateTimePicker1.Value;
o1.description = textBox1.Text;
db.orderTBL.Add(o1);
db.SaveChanges();
MessageBox.Show("ההזמנה עודכנה בהצלחה");
custWin_Load(sender, e);
}
private void custWin_Load(object sender, EventArgs e)
{
label4.Text = "";
label5.Text = "";
var tmp = (from s in db.customerTBL select s).ToList();
comboBox1.DataSource = tmp;
comboBox1.DisplayMember = "FirstName";
comboBox1.ValueMember = "Id";
var tmp2 = (from s in db.orderTBL orderby s.date select s).ToList();
dataGridView1.DataSource = tmp2;
dataGridView1.Columns[0].HeaderText = "מס הזמנה";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
customerTBL c1 = (customerTBL)comboBox1.SelectedItem;
label4.Text = c1.FirstName;
label5.Text = c1.LastName;
}
}
}