private void btnAdd_Click(object sender, EventArgs e) { using (DataClassesDataContext db = new DataClassesDataContext()) { if (tbxName.Text == "" || tbxPrice.Text == "" || tbxQty.Text == "" || cbxMember.SelectedItem == null) { MessageBox.Show("Data Cant Be Empty", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); bersih(); } else { menuu m = list.Where(s => s.kodemenu == kodeid).FirstOrDefault(); if (m != null) { m.Qty += Convert.ToInt32(tbxQty.Text); } else { list.Add(new menuu { kodemenu = kodeid, namamember = cbxMember.SelectedItem.ToString(), namamenu = tbxName.Text, Price = Convert.ToInt32(tbxPrice.Text), Qty = Convert.ToInt32(tbxQty.Text) }); } refreshlabel(); refreshdg(); } } }
private void dg2_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { selected = new menuu(); selected = list[e.RowIndex]; } }