protected void btnSubmit_Click(object sender, EventArgs e) { var t = new Task(); var tc = new TaskController(); if (ItemId > 0) { t = tc.GetItem(ItemId, UserId); t.Title = txtName.Text.Trim(); t.Description = txtDescription.Text.Trim(); t.LastModifiedByUserId = UserId; t.LastModifiedOnDate = DateTime.Now; t.AssignedUserId = Convert.ToInt32(ddlAssignedUser.SelectedValue); } else { t = new Task() { AssignedUserId = Convert.ToInt32(ddlAssignedUser.SelectedValue), CreatedByUserId = UserId, CreatedOnDate = DateTime.Now, Title = txtName.Text.Trim(), Description = txtDescription.Text.Trim(), }; } t.LastModifiedOnDate = DateTime.Now; t.LastModifiedByUserId = UserId; if (t.TaskId > 0) { tc.UpdateItem(t); } else { tc.CreateItem(t); } Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); }
protected void Page_Load(object sender, EventArgs e) { try { //Implement your edit logic for your module if (!Page.IsPostBack) { //get a list of users to assign the user to the Object ddlAssignedUser.DataSource = UserController.GetUsers(PortalId); ddlAssignedUser.DataTextField = "Username"; ddlAssignedUser.DataValueField = "UserId"; ddlAssignedUser.DataBind(); //check if we have an ID passed in via a querystring parameter, if so, load that item to edit. //ItemId is defined in the ItemModuleBase.cs file if (ItemId > 0) { var tc = new TaskController(); var t = tc.GetItem(ItemId, UserId); if (t != null) { txtName.Text = t.Title; txtDescription.Text = t.Description; ddlAssignedUser.Items.FindByValue(t.AssignedUserId.ToString()).Selected = true; } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }