예제 #1
0
 private void FillBox()
 {
     ItemListSort = -1;
     lstBoxSiblingItems.Items.Clear();
     if (Item != null)
     {
         using (HyperComponents.Data.dbAccess.Database dbObj = Utils.GetMainDB())
         {
             using (DataTable siblingItems = dbObj.RunSPReturnDataSet("_Item_GetSiblingItems", new System.Data.SqlClient.SqlParameter("@ItemId", Item.Id)).Tables[0])
             {
                 dbObj.CloseConnection();
                 if (siblingItems != null && siblingItems.Rows.Count > 0)
                 {
                     lstBoxSiblingItems.Size = siblingItems.Rows.Count + 1;
                 }
                 if (siblingItems.Rows.Count > 14)
                 {
                     lstBoxSiblingItems.Size = 15;
                 }
                 for (int i = 0; i < siblingItems.Rows.Count; i++)
                 {
                     string itemName   = siblingItems.Rows[i]["ItemName"].ToString();
                     string itemNumber = siblingItems.Rows[i]["ItemNumber"].ToString();
                     itemName = itemNumber.Length > 0 ? "[" + itemNumber + "] - " + itemName : itemName;
                     ListItem newItem = new ListItem("[" + siblingItems.Rows[i]["LevelId"].ToString() + "] - " + itemName, siblingItems.Rows[i]["ItemId"].ToString().ToString());
                     if (newItem.Text.Length > 80)
                     {
                         newItem.Text = newItem.Text.Substring(0, 49) + "...";
                     }
                     lstBoxSiblingItems.Items.Add(newItem);
                 }
             }
         }
     }
 }
예제 #2
0
 protected DataSet GetSearchResults()
 {
     if (Session["SearchResult"] == null)
     {
         using (HyperComponents.Data.dbAccess.Database dbObj = Utils.GetMainDB())
         {
             Session["SearchResult"] = dbObj.RunSPReturnDataSet("_Item_Search", new SqlParameter("@SearchString", searchString),
                                                                new SqlParameter("@UserId", SessionState.User.Id), new SqlParameter("@CultureCode", SessionState.Culture.Code),
                                                                new SqlParameter("@CompanyName", SessionState.CompanyName));
         }
     }
     return((DataSet)Session["SearchResult"]);
 }
예제 #3
0
        protected void advancedToolBar_ButtonClicked(object sender, Infragistics.WebUI.UltraWebToolbar.ButtonEvent be)
        {
            advancedToolBar.ClientSideEvents.InitializeToolbar = "";
            uwToolbar.Items.FromKeyButton("Export").Pressed(true);
            switch (be.Button.Key)
            {
            case "TotalExport":
                using (HyperComponents.Data.dbAccess.Database dbObj = new HyperComponents.Data.dbAccess.Database(SessionState.CacheComponents["CRYSTAL_DB"].ConnectionString))
                {
                    string code = DDL_TermTypeList.SelectedIndex > 0 ? DDL_TermTypeList.SelectedValue.ToString() : string.Empty;
                    using (DataSet ds = dbObj.RunSPReturnDataSet("_Term_Export", new System.Data.SqlClient.SqlParameter("@TermTypeCode", code)))
                    {
                        code = code == string.Empty ? " " : code;                     // assigning the code to have empty space if it is empty
                        using (TermType tt = TermType.GetByKey(Convert.ToChar(code))) // If the code value is " ", then tt would be null
                        {
                            code = code != " " ? tt.Name : "All terms";
                        }
                        HyperCatalog.UI.Tools.Export.ExportTermReport(ds, code, this.Page);
                    }
                }
                break;

            case "RunValidationReport":
                using (HyperComponents.Data.dbAccess.Database dbObj = new HyperComponents.Data.dbAccess.Database(SessionState.CacheComponents["CRYSTAL_DB"].ConnectionString))
                {
                    Infragistics.WebUI.WebSchedule.WebDateChooser startDate = (Infragistics.WebUI.WebSchedule.WebDateChooser)advancedToolBar.Items.FromKeyCustom("startDate").FindControl("startDate");
                    if (startDate != null)
                    {
                        using (DataSet ds = dbObj.RunSPReturnDataSet("_Term_GetChoicesValidationReport", new System.Data.SqlClient.SqlParameter("@DayNew", startDate.Value)))
                        {
                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                HyperCatalog.UI.Tools.Export.ExportTermValidationReport(ds, (DateTime)startDate.Value, Page);
                            }
                            else
                            {
                                errorMsg.Text    = "No activity since this date.";
                                errorMsg.Visible = true;
                            }
                        }
                    }
                }
                break;

            default:
                Response.Write("coucou");
                break;
            }
        }
예제 #4
0
        private void Save()
        {
            using (HyperComponents.Data.dbAccess.Database dbObj = Utils.GetMainDB())
            {
                // Default value
                lbError.Visible = false;
                lbError.Text    = string.Empty;

                if (pnlMasterPublishing.Visible)
                {
                    cbMasterPublishing.Visible = false;
                }

                bool   isClosed = false;
                string s        = string.Empty;
                if (rbDraft.Checked)
                {
                    s = HyperCatalog.Business.ChunkStatus.Draft.ToString();
                }
                else if (rbFinal.Checked)
                {
                    s = HyperCatalog.Business.ChunkStatus.Final.ToString();
                }

                Item curItem = item;
                curItem.RegionCode = culture.Code;

                if (item.GetRoll() != null && rdSoftRoll.Checked)
                {
                    curItem = item.GetRoll();
                }

                if (s.Length > 0)
                {
                    #region "Save Master publishing date if necessary"
                    if (cbMasterPublishing.Checked)
                    {
                        if (wdMasterPublishing.Value != null)
                        {
                            #region "Save Master Publishing Date Chunk"
                            if (SessionState.Culture.Type == HyperCatalog.Business.CultureType.Master)
                            {
                                // 69605 issue fix
                                // Use a SP to directly add/update the MPD chunk is ALL childs
                                DateTime d   = (DateTime)wdMasterPublishing.Value;
                                string   mpd = d.Month.ToString() + '/' + d.Day.ToString() + '/' + d.Year.ToString();
                                dbObj.RunSPReturnInteger("_Item_MPDAddUpd", new SqlParameter("@ItemId", curItem.Id), new SqlParameter("@IncludeChildren", cbWithChildren.Checked), new SqlParameter("@MasterPublishingDate", mpd), new SqlParameter("@UserId", SessionState.User.Id));
                            }
                            #endregion
                        }
                        else
                        {
                            // Error: missing Master Publishing Date
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MissingMasterPublishingDate", "<script>alert('Please provide a valid [master publishing date]');</script>");
                            return;
                        }
                    }
                    #endregion

                    //// Modified by Prabhu for ACQ 3.0 (PCF1: Regional Project Management)-- 18/May/09
                    //// Comment out as not needed after Regional Project Management
                    //// You cannot override a region project date from master.
                    #region "Save Project Dates"

                    /*
                     * // if item is already a project
                     * curItem.Milestones.ItemId = curItem.Id;
                     * curItem.Milestones.RegionCode = culture.Code;
                     * if (curItem.Milestones != null && culture.Type == CultureType.Regionale && inputFormId < 0)
                     * {
                     *  if (!curItem.Milestones.Inherited)
                     *  {
                     *      bool updateProjectDate = false;
                     *      // Force Master Acquisition Date to be NOW since the validation is done
                     *      // The product can now be visibile at regional level
                     *      if (curItem.Milestones.BeginningOfRegionalization == null)
                     *      {
                     *          curItem.Milestones.BeginningOfRegionalization = DateTime.UtcNow;
                     *          updateProjectDate = true;
                     *      }
                     *      if ((curItem.Milestones.EndOfRegionalization.HasValue && curItem.Milestones.EndOfRegionalization > DateTime.UtcNow) || curItem.Milestones.EndOfRegionalization == null)
                     *      {
                     *          curItem.Milestones.EndOfRegionalization = DateTime.UtcNow;
                     *          updateProjectDate = true;
                     *      }
                     *      if(updateProjectDate)
                     *      {
                     *          if (!curItem.Milestones.Save(user.Id))
                     *          {
                     *              lbError.CssClass = "hc_error";
                     *              lbError.Text = HyperCatalog.Business.ItemDates.LastError;
                     *              lbError.Visible = true;
                     *              return;
                     *          }
                     *      }
                     *  }
                     * }
                     */
                    #endregion

                    //#region "Move status Draft, Rejected --> Final or Final, Rejected --> Draft, if possible" --Alternate for CR 5096
                    #region "Move status Draft --> Final or Final --> Draft, if possible"
                    HyperCatalog.Business.ChunkStatus status = (HyperCatalog.Business.ChunkStatus)Enum.Parse(typeof(HyperCatalog.Business.ChunkStatus), s);
                    if (!curItem.MoveContentToStatus(culture.Code, status, user.Id, cbWithChildren.Checked, inputFormId, containerMATFList))
                    {
                        lbError.CssClass = "hc_error";
                        lbError.Text     = HyperCatalog.Business.Item.LastError;
                        lbError.Visible  = true;
                        return;
                    }
                    else
                    {
                        if (culture.Code == SessionState.MasterCulture.Code && inputFormId < 0)
                        {
                            string includeChildren = cbWithChildren.Checked?"1":"0";
                            using (DataSet ds = dbObj.RunSQLReturnDataSet("NOTIFICATION_NotifyRegionalUsersMasterValidationOnMATF " + item.Id + ", " + includeChildren))
                            {
                                dbObj.CloseConnection();
                                if (dbObj.LastError != string.Empty)
                                {
                                    lbError.CssClass = "hc_error";
                                    lbError.Text     = "System was not able to notify regional users [" + dbObj.LastError + "]";
                                    lbError.Visible  = true;
                                }
                                else
                                {
                                    if (ds != null && ds.Tables.Count == 1)
                                    {
                                        string message = "New products are available at regional level, you can click <a href='";
                                        message += HyperCatalog.Business.ApplicationSettings.Components["Crystal_UI"].URI;
                                        message += "/UI/Collaborate/NPIReport.aspx'>here</a> to access the full list.";

                                        foreach (DataRow dr in ds.Tables[0].Rows)
                                        {
                                            Utils.SendMail(dr["Email"].ToString(), dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), "New products in region notification", message, false);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    // ds contains all content
                    using (DataSet ds = dbObj.RunSPReturnDataSet("dbo._Item_GetAllContent", "Content",
                                                                 new SqlParameter("@ItemId", curItem.Id),
                                                                 new SqlParameter("@CultureCode", culture.Code),
                                                                 new SqlParameter("@InputFormId", inputFormId),
                                                                 new SqlParameter("@WithChildren", cbWithChildren.Checked),
                                                                 new SqlParameter("@MoveStatus", 1)))
                    {
                        dbObj.CloseConnection();
                        if (dbObj.LastError.Length > 0)
                        {
                            lbError.CssClass = "hc_error";
                            lbError.Text     = HyperCatalog.Business.Item.LastError;
                            lbError.Visible  = true;
                        }
                        else
                        {
                            #region "Force translation to draft"
                            if (cbForceTranslation.Checked && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                string containerList = string.Empty;
                                foreach (DataRow dr in ds.Tables[0].Rows)
                                {
                                    if (dr["ContainerId"] != null)
                                    {
                                        if (containerList.Length > 0)
                                        {
                                            containerList += ",";
                                        }
                                        containerList += dr["ContainerId"].ToString();
                                    }
                                }

                                if (containerList.Length > 0)
                                {
                                    if (!curItem.ForceTranslationsToDraft(culture.Code, containerList, user.Id))
                                    {
                                        lbError.CssClass = "hc_error";
                                        lbError.Text     = HyperCatalog.Business.Item.LastError;
                                        lbError.Visible  = true;
                                        return;
                                    }
                                }
                            }
                            #endregion

                            #region "Generate report"
                            if (cbReport.Checked && ds != null)
                            {
                                // Create report
                                GenerateReport(ds, curItem.Id);


                                // Refresh frame content and close window
                                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "closePopup", "<script>window.close();</script>");
                            }
                        }
                        #endregion
                    }

                    SessionState.CurrentItem = null;

                    // Refresh frame content and close window
                    if (SessionState.CurrentItem != null && SessionState.User.LastVisitedItem != SessionState.CurrentItem.Id)
                    {
                        SessionState.User.LastVisitedItem = curItem.Id;
                        SessionState.User.QuickSave();
                    }
                    if (SessionState.QDEChunk != null)
                    {
                        SessionState.QDEChunk.Dispose();
                    }
                    if (SessionState.QDEContainer != null)
                    {
                        SessionState.QDEContainer.Dispose();
                    }
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "updateGrid", "<script>UpdateAndClose(1, " + inputFormId.ToString() + ");</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MissingStatus", "<script>alert('Select the status (Draft or Final)');</script>");
                }
            }
        }