public bool Remove(PopupUserObject popupUser) { SqlCommand cmd = null; try { ExecuteNonQuery(out cmd, false, "PopupUser_DELETE", CreateParameter("@popupuserID", SqlDbType.UniqueIdentifier, popupUser.PopupUserID, ParameterDirection.Input) ); return(true); } catch (Exception exception1) { Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } finally { if (cmd != null) { cmd.Dispose(); } cmd = null; } }
public void Save(PopupUserObject popupUser) { SqlCommand cmd = null; try { ExecuteNonQuery(out cmd, false, "PopupUser_Save", CreateParameter("@popupuserID", SqlDbType.UniqueIdentifier, popupUser.PopupUserID, ParameterDirection.InputOutput), CreateParameter("@popupID", SqlDbType.UniqueIdentifier, popupUser.Popup.PopupID), CreateParameter("@userID", SqlDbType.UniqueIdentifier, popupUser.User == null ? Guid.Empty : popupUser.User.UsrID) ); popupUser.PopupUserID = (Guid)cmd.Parameters["@popupuserID"].Value; } catch (Exception exception1) { Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } finally { if (cmd != null) { cmd.Dispose(); } cmd = null; } }
private void btnSave_Click(object sender, EventArgs e) { try { _popup.Description = memoDescription.Text; _popup.Active = cbxActive.Checked; _popup.CreationDate = PROF_IT.Common.Convert.DateFunctions.DateToStrDate(dteStartDate.DateTime); _popup.Repeation = (Enumeration.Frequency.TimeFrequency)cmbFrequency.EditValue; if (txtTimeOfDay.Text.Length == 7) { _popup.Time = "0" + txtTimeOfDay.Text.Replace(":", ""); } else { _popup.Time = txtTimeOfDay.Text.Replace(":", ""); } //Save parent to have the correct GUID ID new BL.Internal.Popup().Save(PopupMember); //Link Popup to all users UserObjectCollection users = new BL.Internal.User().GetAll(); foreach (UserObject user in users) { PopupUserObject popupUser = new PopupUserObject(); popupUser.Popup = _popup; popupUser.State = PROF_IT.Common.Enumerations.ObjectState.Created; popupUser.User = user; _popup.PopupUsers.Add(popupUser); } //Save Parent with childs new BL.Internal.Popup().Save(PopupMember); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch (System.Exception exception1) { System.Exception thisException = exception1; Management.ShowException(thisException); } }