protected void Page_Load(object sender, EventArgs e) { try { //Implement your edit logic for your module if (!Page.IsPostBack) { //check if we have an ID passed in via a querystring parameter, if so, load that Device to edit. //DeviceId is defined in the DeviceModuleBase.cs file if (DeviceId > 0) { var tc = new DeviceController(); var t = tc.GetDevice(DeviceId, ModuleId); if (t != null) { txtName.Text = t.DeviceName; txtDescription.Text = t.DeviceDescription; } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void btnSubmit_Click(object sender, EventArgs e) { var t = new Device(); var tc = new DeviceController(); //TODO: populate device properties if (DeviceId > 0) { t = tc.GetDevice(DeviceId, ModuleId); t.DeviceName = txtName.Text.Trim(); t.DeviceDescription = txtDescription.Text.Trim(); t.LastModifiedByUserId = UserId; t.LastModifiedOnDate = DateTime.Now; } else { t = new Device() { CreatedByUserId = UserId, CreatedOnDate = DateTime.Now, DeviceName = txtName.Text.Trim(), DeviceDescription = txtDescription.Text.Trim(), }; } t.LastModifiedOnDate = DateTime.Now; t.LastModifiedByUserId = UserId; t.ModuleId = ModuleId; if (t.Id > 0) { tc.UpdateDevice(t); } else { tc.CreateDevice(t); } Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); }