Esempio n. 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("هل تريد مسح تلك البيانات ؟", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    var selectedrow = item_masterDataGridView.SelectedRows.OfType <DataGridViewRow>().Where(r => !r.IsNewRow).ToArray();
                    using (var tiba = new TibaContext())
                    {
                        foreach (var i in selectedrow)
                        {
                            var record = tiba.ItemMaster.Where(x => x.Id == int.Parse(i.Cells[0].Value.ToString())).First();
                            tiba.ItemMaster.Remove(record);
                        }


                        tiba.SaveChanges();
                        this.item_masterTableAdapter.Dispose();
                        this.item_masterTableAdapter.Fill(this.tibasport_dbDataSet.item_master);
                    }

                    c.set_autoinc("item_master", "id", item_masterDataGridView);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.InnerException.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                }
            }
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         customerBindingSource.EndEdit();
         customerTableAdapter.Update(this.tibasport_dbDataSet.customer);
         c.set_autoinc("customer", "Id", dgViewCustomer);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         MessageBox.Show("تم عملية الحفظ بنجاح", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     Cursor.Current = Cursors.Default;
 }