Example #1
0
        /// <summary>
        /// Handles Page_Load event for a control
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // parse querystring parameters
                int tmpItemId;
                if (int.TryParse(Request.QueryString ["InventionID"], out tmpItemId))
                {
                    itemId = tmpItemId;
                }

                if (!IsPostBack)
                {
                    // load the data into the control the first time we hit this page

                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    // check we have an item to lookup
                    // ALT: if (!Null.IsNull (itemId)
                    if (itemId.HasValue)
                    {
                        // load the item
                        var ctrl = new ObserverOfScienceController();
                        var item = ctrl.Get <InventionInfo> (itemId.Value, this.ModuleId);

                        if (item != null)
                        {
                            //TODO: Fill controls with data
                            txtTitle.Text = item.Name;
                            //	txtListOfDevelopment.Text=item.ListOfDevelopment;
                            //txtDevelopment.Text=item.Development;
                            txtDescription.Text = item.Description;
                            //	txtYearOfDevelopment.Text = item.YearOfDevelopment.ToString();
                            //setup audit control;
                            //ctlAudit.CreatedByUser = item.CreatedByUserName;
                            //	ctlAudit.CreatedDate = item.CreatedOnDate.ToLongDateString ();
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// Handles the items being bound to the datalist control. In this method we merge the data with the
        /// template defined for this control to produce the result to display to the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lstContent_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
        {
            // use e.Item.DataItem as object of ObserverOfScienceInfo class,
            // as we really know it is:
            var item1 = e.Item.DataItem as ObserverOfScienceInfo;
            var ctrl  = new ObserverOfScienceController();

            var item = ctrl.Get <InventionInfo> (item1.InventionId);

            var HyperName  = e.Item.FindControl("HyperName") as HyperLink;
            var lblContent = e.Item.FindControl("lblContent") as Label;
            //в таблице нет  поля статусvar lblStatus = e.Item.FindControl ("lblStatus") as Label;
            //	var lblScientists = e.Item.FindControl ("lblScientists") as Label;
            var ImgObserverOfScience = e.Item.FindControl("ImgObserverOfScience") as Image;
            //var CreateByUser = e.Item.ForeControl ("CreateByUser") as Label;
            var contentValue = string.Empty;

            var edit = e.Item.FindControl("HyperLink1") as HyperLink;

            edit.NavigateUrl = EditUrl("InventionID", item.InventionID.ToString());

            if (item.Image != null)
            {
                ImgObserverOfScience.ImageUrl = item.Image;
            }
            else
            {
                ImgObserverOfScience.ImageUrl = "~/DesktopModules/ObserverOfScience/images/irrigation.jpg";
            }



            HyperName.NavigateUrl = EditUrl("ObserverOfScienceID", item.InventionID.ToString(), "DetailView");
            linkinvention         = HyperName.NavigateUrl;
            contentValue          = Server.HtmlDecode(item.Description);
            HyperName.Text        = contentValue;

            //	contentValue = Server.HtmlDecode (LenghtText(item.Content));
            //	lblContent.Text = contentValue;

            contentValue = Server.HtmlDecode(item.Name);
            //lblStatus.Text =string.Format(Localization.GetString("lblTitle.Format", LocalResourceFile), contentValue);
            contentValue = null;
            //	foreach(ScientistInfo ind in item.Scientists)
            //	{
            //		contentValue+=ind.User.LastName+" "+ind.User.FirstName+";";
            //	}
            //	lblScientists.Text=string.Format(Localization.GetString("lblScientists.Format", LocalResourceFile),contentValue);
        }
Example #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);
            }
        }
        /// <summary>
        /// Handles Page_Load event for a control
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// Event args.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int tmpItemId;
                if (int.TryParse(Request.QueryString ["InventionID"], out tmpItemId))
                {
                    itemId = tmpItemId;
                }
                if (!IsPostBack)
                {
                    if (itemId.HasValue)
                    {
                        // load the item
                        var ctrl         = new ObserverOfScienceController();
                        var item         = ctrl.Get <InventionInfo> (itemId.Value);
                        var contentValue = string.Empty;
                        if (item != null)
                        {
                            lblDetailInventionEssence.Text = item.Description + "<p>" + item.InventionEssence;
                            lblDetailName.Text             = item.Name;

                            //	lblDetailStatus.Text=string.Format(Localization.GetString("lblDetailStatus.Format", LocalResourceFile),item.Status);
                            lblDetailStatus.Text = item.Status;
                            lblAdvantages.Text   = item.Advantages;

                            if (item.YearOfCreation.Year != 1)
                            {
                                lblYearOfCreation.Text = "<b>Год разработки:</b>" + item.YearOfCreation.Year.ToString() + "г.";
                            }
                            foreach (ScientistInfo ind in item.Scientists)
                            {
                                contentValue += ind.User.LastName + " " + ind.User.FirstName + ";" + "<br>";
                            }
                            lblDetailScientist.Text = contentValue;
                            //lblDetailScientist.Text=string.Format(Localization.GetString("lblDetailScientist.Format", LocalResourceFile),contentValue);

                            #region Патент

                            RepeaterPatent.DataSource = item.Patents;
                            RepeaterPatent.DataBind();
                            if (patent == 0)
                            {
                                lblPatent.Text = "Патенты отсутсвуют";
                            }
                            #endregion

                            #region Термы
                            RepeaterTerms.DataSource = item.Terms;
                            RepeaterTerms.DataBind();
                            #endregion

                            #region  есурсы
                            RepeaterResources.DataSource = item.InventionResources;
                            RepeaterResources.DataBind();
                            if (patent != 2)
                            {
                                lblResources.Text = "У данной разработки материалы отсутствуют";
                            }
                            #endregion

                            #region Внедрения
                            if (item.Introductions.Count > 0)
                            {
                                foreach (IntroductionInfo introduction in item.Introductions)
                                {
                                    lblIntroduction.Text   = "<b>Была внедренна:</b><br/>";
                                    HyperIntroduction.Text = "<i>" + introduction.Vendor.VendorName + "</i>";
                                    YearIntroduction.Text  = " В " + introduction.YearIntroduction.Date.Year + "г.";
                                }
                            }
                            else
                            {
                                lblIntroduction.Text = "Разработка ещё не внедрялась";
                            }


                            #endregion
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }