private void button3_Click(object sender, EventArgs e) { if ((MessageBox.Show("هل متأكد من حذف العنصر المحدد", "عملية الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)) { models.Masrofat ms = new models.Masrofat(); ms.id = Int32.Parse(DataGrid.CurrentRow.Cells[0].Value.ToString()); crd.masrofat(ms, System.Data.Entity.EntityState.Deleted); fill_grid(); MessageBox.Show("تم الحذف بنجاح"); } }
private void button1_Click(object sender, EventArgs e) { if (metroTextBox1.Text == string.Empty || metroTextBox2.Text == string.Empty) { label5.Text = "ادخل البيانات سليمه"; return; } models.Masrofat ms = new models.Masrofat() { name = metroTextBox1.Text, price = decimal.Parse(metroTextBox2.Text), notes = metroTextBox3.Text, date = dateTimePicker1.Value, Quantity = decimal.Parse(textBox1.Text) }; crd.masrofat(ms, System.Data.Entity.EntityState.Added); MessageBox.Show("تم الاضافة بنجاح"); Close(); }