/// <summary>
        /// Imports a module from an XML
        /// </summary>
        /// <param name="ModuleID"></param>
        /// <param name="Content"></param>
        /// <param name="Version"></param>
        /// <param name="UserID"></param>
        public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        {
            var infos = DotNetNuke.Common.Globals.GetContent(Content, "ObserverOfSciences");

            foreach (XmlNode info in infos.SelectNodes("ObserverOfScience"))
            {
                var item = new ObserverOfScienceInfo();
                item.ModuleID = ModuleID;
                //item.Content = info.SelectSingleNode ("content").InnerText;
                item.CreatedByUser = UserID;

                Add <ObserverOfScienceInfo> (item);
            }
        }
        /// <summary>
        /// Handles Click event for cmdUpdate button
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var ctrl = new ObserverOfScienceController ();
                ObserverOfScienceInfo item;
                InventionInfo inv;

                // determine if we are adding or updating
                // ALT: if (Null.IsNull (itemId))
                if (!itemId.HasValue)
                {
                    // TODO: populate new object properties with data from controls
                    // to add new record
                    //Описание разработки
                    inv = new InventionInfo();
                    inv.Description = txtDescription.Text;
                    inv.Status = txtStatus.Text;
                    inv.YearOfCreation = DateTime.Today;// временно
                    inv.Advantages = txtAdvantages.Text;
                    inv.InventionEssence = txtInventionEssence.Text;

                    inv.Name = txtTitle.Text;
                    ctrl.Add<InventionInfo>(inv);

                    item = new ObserverOfScienceInfo ();
                    item.ModuleID = ModuleId;
                    item.CreatedByUser = this.UserId;
                    item.InventionId = inv.InventionID;
                    ctrl.Add<ObserverOfScienceInfo> (item);

                    //inv.Name = txtTitle.Text;
                    //ctrl.Add<InventionInfo>(inv);

                    //Суть разработки

                    //inv.Name = txtTitle.Text;
                    //ctrAdd<InventionInfo>(inv);

                }
                else
                {

                    inv = ctrl.Get<InventionInfo> (itemId.Value);
                    inv.Description = txtDescription.Text;
                    inv.Advantages = txtAdvantages.Text;
                    inv.InventionEssence = txtInventionEssence.Text;
                    inv.Name = txtTitle.Text;
                    ctrl.Update<InventionInfo>(inv);

                    /*
                    inv = ctrl.Get<InventionInfo> (itemId.Value);
                    inv.Advantages = txtTitle.Text;
                    ctrl.Update<InventionInfo>(inv);
                    inv = ctrl.Get<InventionInfo> (itemId.Value);
                    inv.Name = txtTitle.Text;
                    ctrl.Update<InventionInfo>(inv);
            */

                    //по аналогии с выше написанным + править поля в таблицах инвеншанинфо и удалить поля из оbserver of sience кроме invenrionid и modulId
                    // TODO: update properties of existing object with data from controls
                    // to update existing record
                    //item = ctrl.Get<ObserverOfScienceInfo> (itemId.Value, this.ModuleId);
                    //item.Content = txtDescription.Text;
                    //ctrl.Update<ObserverOfScienceInfo> (item);
                }

                Response.Redirect (Globals.NavigateURL (), true);
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException (this, ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Handles Click event for cmdUpdate button
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                var ctrl = new ObserverOfScienceController();
                ObserverOfScienceInfo item;
                InventionInfo         inv;


                // determine if we are adding or updating
                // ALT: if (Null.IsNull (itemId))
                if (!itemId.HasValue)
                {
                    // TODO: populate new object properties with data from controls
                    // to add new record
                    //Описание разработки
                    inv                  = new InventionInfo();
                    inv.Description      = txtDescription.Text;
                    inv.Status           = txtStatus.Text;
                    inv.YearOfCreation   = DateTime.Today;                  // временно
                    inv.Advantages       = txtAdvantages.Text;
                    inv.InventionEssence = txtInventionEssence.Text;

                    inv.Name = txtTitle.Text;
                    ctrl.Add <InventionInfo>(inv);


                    item               = new ObserverOfScienceInfo();
                    item.ModuleID      = ModuleId;
                    item.CreatedByUser = this.UserId;
                    item.InventionId   = inv.InventionID;
                    ctrl.Add <ObserverOfScienceInfo> (item);


                    //inv.Name = txtTitle.Text;
                    //ctrl.Add<InventionInfo>(inv);

                    //Суть разработки


                    //inv.Name = txtTitle.Text;
                    //ctrAdd<InventionInfo>(inv);
                }
                else
                {
                    inv                  = ctrl.Get <InventionInfo> (itemId.Value);
                    inv.Description      = txtDescription.Text;
                    inv.Advantages       = txtAdvantages.Text;
                    inv.InventionEssence = txtInventionEssence.Text;
                    inv.Name             = txtTitle.Text;
                    ctrl.Update <InventionInfo>(inv);


                    /*
                     * inv = ctrl.Get<InventionInfo> (itemId.Value);
                     * inv.Advantages = txtTitle.Text;
                     * ctrl.Update<InventionInfo>(inv);
                     * inv = ctrl.Get<InventionInfo> (itemId.Value);
                     * inv.Name = txtTitle.Text;
                     * ctrl.Update<InventionInfo>(inv);
                     */

                    //по аналогии с выше написанным + править поля в таблицах инвеншанинфо и удалить поля из оbserver of sience кроме invenrionid и modulId
                    // TODO: update properties of existing object with data from controls
                    // to update existing record
                    //item = ctrl.Get<ObserverOfScienceInfo> (itemId.Value, this.ModuleId);
                    //item.Content = txtDescription.Text;
                    //ctrl.Update<ObserverOfScienceInfo> (item);
                }

                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }