コード例 #1
0
		/// <summary>
		/// Handles Click event for Update button
		/// </summary>
		/// <param name='sender'>
		/// Sender.
		/// </param>
		/// <param name='e'>
		/// Event args.
		/// </param>
		protected void buttonUpdate_Click (object sender, EventArgs e)
		{
			try
			{
				EduProgramInfo item;

				// determine if we are adding or updating
				// ALT: if (Null.IsNull (itemId))
				if (!itemId.HasValue)
				{
					// add new record
					item = new EduProgramInfo ();
				}
				else
				{
					// update existing record
					item = LaunchpadController.Get<EduProgramInfo> (itemId.Value);
				}

				// fill the object
				item.Code = textCode.Text.Trim ();
				item.Title = textTitle.Text.Trim ();
                item.ProfileCode = textProfileCode.Text.Trim ();
                item.ProfileTitle = textProfileTitle.Text.Trim ();

                item.EduLevelID = int.Parse (comboEduLevel.SelectedValue);

				if (!itemId.HasValue)
                    LaunchpadController.Add<EduProgramInfo> (item);
				else
                    LaunchpadController.Update<EduProgramInfo> (item);

				Utils.SynchronizeModule (this);

				Response.Redirect (Globals.NavigateURL (), true);
			}
			catch (Exception ex)
			{
				Exceptions.ProcessModuleLoadException (this, ex);
			}
		}
コード例 #2
0
        public void UpdateEduProgram (EduProgramInfo eduProgram, IList<DocumentInfo> documents)
        {
            using (var ctx = DataContext.Instance ())
            {
                ctx.BeginTransaction ();

                try
                {
                    // update edu program
                    Update<EduProgramInfo> (eduProgram);

                    var documentIds = documents.Select (d => d.DocumentID.ToString ());
                    if (documentIds.Any ())
                    {
                        // delete specific documents
                        Delete<DocumentInfo> (string.Format ("WHERE [ItemID] = N'{0}' AND [DocumentID] NOT IN ({1})", 
                            "EduProgramID=" + eduProgram.EduProgramID,
                            Utils.FormatList (", ", documentIds))); 
                    }
                    else
                    {
                        // delete all edu program documents
                        Delete<DocumentInfo> (string.Format ("WHERE [ItemID] = N'EduProgramID={0}'", eduProgram.EduProgramID)); 
                    }

                    // add new documents
                    foreach (var document in documents)
                    {
                        document.ItemID = "EduProgramID=" + eduProgram.EduProgramID;
                        if (document.DocumentID <= 0)
                            Add<DocumentInfo> (document);
                        else
                            Update<DocumentInfo> (document);
                    }

                    ctx.Commit ();
                }
                catch
                {
                    ctx.RollbackTransaction ();
                    throw;
                }
            }
        }
コード例 #3
0
		/// <summary>
		/// Handles Click event for Update button
		/// </summary>
		/// <param name='sender'>
		/// Sender.
		/// </param>
		/// <param name='e'>
		/// Event args.
		/// </param>
		protected void buttonUpdate_Click (object sender, EventArgs e)
		{
			try
			{
				EduProgramInfo item;

				// determine if we are adding or updating
				// ALT: if (Null.IsNull (itemId))
				if (!itemId.HasValue)
				{
					// add new record
					item = new EduProgramInfo ();
				}
				else
				{
					// update existing record
					item = LaunchpadController.Get<EduProgramInfo> (itemId.Value);
				}

				// fill the object
				item.Code = textCode.Text.Trim ();
				item.Title = textTitle.Text.Trim ();
                item.Generation = textGeneration.Text.Trim ();
                item.AccreditedToDate = dateAccreditedToDate.SelectedDate;
                item.StartDate = datetimeStartDate.SelectedDate;
                item.EndDate = datetimeEndDate.SelectedDate;
                item.EduLevelID = int.Parse (comboEduLevel.SelectedValue);

                if (itemId == null)
                {
                    item.CreatedOnDate = DateTime.Now;
                    item.LastModifiedOnDate = item.CreatedOnDate;
                    item.CreatedByUserID = UserInfo.UserID;
                    item.LastModifiedByUserID = item.CreatedByUserID;
                    LaunchpadController.AddEduProgram (item, formEditDocuments.GetData ());
                }
				else
                {
                    item.LastModifiedOnDate = DateTime.Now;
                    item.LastModifiedByUserID = UserInfo.UserID;

                    // REVIEW: Solve on SqlDataProvider level on upgrage to 2.0.0?
                    if (item.CreatedOnDate == default (DateTime)) 
                    {
                        item.CreatedOnDate = item.LastModifiedOnDate;
                        item.CreatedByUserID = item.LastModifiedByUserID;
                    }

                    LaunchpadController.UpdateEduProgram (item, formEditDocuments.GetData ());
                }

				Utils.SynchronizeModule (this);

				Response.Redirect (Globals.NavigateURL (), true);
			}
			catch (Exception ex)
			{
				Exceptions.ProcessModuleLoadException (this, ex);
			}
		}
コード例 #4
0
        public void AddEduProgram (EduProgramInfo eduProgram, IList<DocumentInfo> documents)
        {
            using (var ctx = DataContext.Instance ())
            {
                ctx.BeginTransaction ();

                try
                {
                    // add edu program
                    Add<EduProgramInfo> (eduProgram);

                    // add new documents
                    foreach (var document in documents)
                    {
                        document.ItemID = "EduProgramID=" + eduProgram.EduProgramID;
                        Add<DocumentInfo> (document);
                    }

                    ctx.Commit ();
                }
                catch
                {
                    ctx.RollbackTransaction ();
                    throw;
                }
            }
        }