コード例 #1
0
        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);
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         var tc = new DeviceController();
         rptItemList.DataSource = tc.GetDevices(ModuleId);
         rptItemList.DataBind();
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
コード例 #3
0
        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());
        }
コード例 #4
0
        public void rptItemListOnItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                Response.Redirect(EditUrl(string.Empty, string.Empty, "Edit", "dId=" + e.CommandArgument));
            }

            if (e.CommandName == "Delete")
            {
                var tc = new DeviceController();
                tc.DeleteDevice(Convert.ToInt32(e.CommandArgument), ModuleId);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }