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 UpdateDetailProject(DetailProject instance);
partial void DeleteDetailProject(DetailProject instance);
partial void InsertDetailProject(DetailProject instance);