public void Add(hospitalCenterTab hosp) { try { db.hospitalCenterTab.Add(hosp); db.SaveChanges(); MessageBox.Show("تم اضاقة سجل مريض بنجاح!!", "عملية الاضافة", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Exception" + ex, ex.Data.ToString()); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (search.Text == "") { MessageBox.Show("يجب تحديد العنصر المراد حذفه!! "); return; } var del = db.hospitalCenterTab.SingleOrDefault(h => h.hoId == HoId); if (MessageBox.Show("هل تريد هذا المركز الطبي" + HoId, "عملية الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (del != null) { db.Entry(del).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } MessageBox.Show("!! تم عملبة الحذف بنجاح ", "الخذف", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("exception " + ex, ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtcode.Text == "" || txtname.Text == "" || txtmobile.Text == "" || hold.EditValue==null) { MessageBox.Show("يجب ادخال المعلوات الضرورية!!", " تنبيه", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information); return; } clinic.clCode = txtcode.Text; clinic.clName = txtname.Text; clinic.hoId = Convert.ToInt32(hold.EditValue); clinic.clAddress = txtaddress.Text; clinic.clNote = txtnote.Text; clinic.isDeleted = false; if (txtmobile.Text == "") { clinic.clMobile = Convert.ToInt32(9670000000); } else { clinic.clMobile = Convert.ToInt32(txtmobile.Text); } var name =db.clinicTab.SingleOrDefault(c=>c.clName==clinic.clName); if (name != null) { MessageBox.Show("المعلومات المدخلة موجودة مسبقا يرجا التاكد عزيزي!!", " تنبيه", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information); return; } db.clinicTab.Add(clinic); db.SaveChanges(); MessageBox.Show("تم الحفظ بنجاح !! تهانينا"); Display(); } catch { throw; } }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { db.SaveChanges(); XtraMessageBox.Show("تم الحفظ بنجاح !!", "تحديث", MessageBoxButtons.OK, MessageBoxIcon.Information); }