private void Open()
 {
     try
     {
         int id = SelectedId;
         if (id != 0)
         {
             Ward ward = null;
             using (GmConnection conn = App.CreateConnection())
             {
                 ward = Ward.GetWard(conn, id);
             }
             if (ward != null)
             {
                 WardForm form = new WardForm(ward);
                 if (form.ShowDialog() == DialogResult.OK)
                 {
                     UpdateRow(SelectedRow, form);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
        private void UpdateRow(DataRow dr, WardForm form)
        {
            Ward ward = form.Ward;

            dr["Id"]           = ward.Id;
            dr["Number"]       = ward.number;
            dr["NumberOfBeds"] = ward.numberOfBeds;
            dr["WardTypeName"] = form.WardTypeName;
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Ward     ward = new Ward();
         WardForm form = new WardForm(ward);
         if (form.ShowDialog() == DialogResult.OK)
         {
             DataRow newRow = dataTable.NewRow();
             dataTable.Rows.Add(newRow);
             UpdateRow(newRow, form);
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }