private void button1_Click(object sender, EventArgs e) { DestinationVO temp = new DestinationVO(); temp.Id = dest.Id; temp.Name = DestTB.Text.Trim(); if (DestTB.Text.Trim() == "") { Error("اسم الوجهة لا يمكن أن يكون فارغاً"); return; } if (!manager.IsDestinationNew(temp)) { Error("هناك وجهة أخرى لها نفس الاسم", "فشل تعديل الوجهة"); return; } else { if (manager.Update(temp)) { dest.Name = temp.Name; Message("تم تعديل الوجهة بنجاح"); DialogResult = System.Windows.Forms.DialogResult.OK; } else { Error(); } } }
private void InsertDestinationButton_Click(object sender, EventArgs e) { DestinationVO dest = new DestinationVO(); dest.Name = DestinationTB.Text.Trim(); if (!manager.IsDestinationNew(dest)) { Error("اسم الوجهة موجود سابقاً", "تعذر إضافة وجهة جديد"); return; } if (DestinationTB.Text.Trim() == "") { Error("اسم الوجهة لا يمكن أن يكون فارغاً"); return; } if (manager.Insert(dest) < 0) { Error("حدث خطأ أثناء عملية إضافة الوجهة", "فشل عملية الإضافة"); } else { bindingSource1.Add(dest); Message("تم إضافة الملف بنجاح", "عملية ناجحة"); DestinationTB.Text = ""; DestinationTB.Focus(); Log(OperationsManager.EDIT_DESTINATIONS); } }
public DestinationEditForm(DestinationVO des, DestinationsManager m) : this() { dest = des; manager = m; isAutomatic = true; DestTB.Text = des.Name; isAutomatic = false; }
private void UpdateDestinationButton_Click(object sender, EventArgs e) { DestinationVO current = bindingSource1.Current as DestinationVO; if (current != null) { DestinationEditForm form = new DestinationEditForm(current, manager); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DestinationDataGridView.Refresh(); Log(OperationsManager.EDIT_DESTINATIONS); } } }
private void RemovDestinationButton_Click(object sender, EventArgs e) { DestinationVO current = bindingSource1.Current as DestinationVO; if (current != null) { if (Question("هل أنت متأكد من الحذف؟") == System.Windows.Forms.DialogResult.Yes) { if (manager.Delete(current)) { bindingSource1.Remove(current); DestinationDataGridView.Refresh(); Message("تم الحذف بنجاح"); Log(OperationsManager.EDIT_DESTINATIONS); } else { Error(); } } } }