public CreateDealForm(int id)
 {
     InitializeComponent();
     showComponents(false);
     db = new DataClasses1DataContext();
     obj = (from x in db.HeaderProjects
            where x.Id == id
            select x).First();
     lbClient.Text = obj.Client;
     lbClient1.Text = obj.Client;
     lbName.Text = obj.Name;
 }
        private void button3_Click(object sender, EventArgs e)
        {
            String pName = textBox1.Text;

            if( pName.Equals("") )
                MessageBox.Show("Project Name must be filled.");
            else if( cart.Count == 0 )
                MessageBox.Show("Shopping Cart is empty.");
            else
            {
                HeaderProject obj = new HeaderProject();
                obj.Client = "";
                obj.CreateDate = dateTimePicker1.Value;
                obj.Description = "";
                obj.Name = pName;
                obj.Note = "";
                obj.Payment = 0;
                obj.Progress = 0;

                db.HeaderProjects.InsertOnSubmit(obj);
                db.SubmitChanges();

                int pId = (from x in db.HeaderProjects
                           orderby x.Id descending
                           select x).First().Id;

                for (int i = 0; i < cart.Count; i++)
                {
                    String[] temp = cart.ElementAt(i).Split('-');

                    int id = int.Parse(temp[0].Trim());
                    String name = temp[1].Trim();
                    int amount = int.Parse(temp[2].Trim());
                    String unit = temp[3].Trim();
                    decimal price = decimal.Parse(temp[4].Trim());
                    decimal sub = decimal.Parse(temp[5].Trim());

                    DetailProject obj2 = new DetailProject();
                    obj2.Amount = amount;
                    obj2.InventoryId = id;
                    obj2.Price = price;
                    obj2.HeaderId = pId;

                    db.DetailProjects.InsertOnSubmit(obj2);
                    db.SubmitChanges();
                }
                ProjectDetailForm pdf = new ProjectDetailForm(pId);
                pdf.MdiParent = this.MdiParent;
                pdf.Show();
                this.Dispose();
            }
        }
 partial void DeleteHeaderProject(HeaderProject instance);
 partial void UpdateHeaderProject(HeaderProject instance);
 partial void InsertHeaderProject(HeaderProject instance);