Esempio n. 1
0
        private void UpdateDataView()
        {
            //***************************************
            // Retrieve Item info
            //***************************************
            dg.Visible       = false;
            lbResult.Visible = false;
            if (item != null && culture != null)
            {
                // Update label for item name
                lbItemName.Text = item.Name + " (" + item.Level.Name + ")";
                if (item.Sku != string.Empty)
                {
                    lbItemName.Text = item.Sku + "-" + lbItemName.Text;
                }

                //using (ChunkList itemChunks = item.Chunks(culture.Code))
                using (HyperComponents.Data.dbAccess.Database dbObj = Utils.GetMainDB())
                {
                    string sSql = "EXECUTE dbo.QDE_GetItemCountryView " + item.Id + ", '" + culture.Code + "', 0 , 0";
                    using (DataSet ds = dbObj.RunSQLReturnDataSet(sSql, "chunks"))
                    {
                        if (ds != null)
                        {
                            dg.DataSource = ds.Tables[0];
                            Utils.InitGridSort(ref dg, false);
                            dg.DataBind();
                            lbcultureName.Text = culture.Name;
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "cultureCode", "<script>l='" + culture.Name + "';</script>");
                        }
                    }
                }
            }

            if (dg != null && dg.Rows != null && dg.Rows.Count > 0)
            {
                dg.Visible = true;
            }
            else
            {
                lbResult.Visible = true;
            }
        }
Esempio n. 2
0
        private void UpdateDataEdit(string countryCode)
        {
            if (countryCode != string.Empty)
            {
                currentCountry = Business.Country.GetByKey(countryCode);
            }
            else
            {
                currentCountry = null;
            }

            txtRegionCodeValue.ClearSelection();
            //using (ItemList classes = Item.GetAll("LevelId=1"))
            //{

            //  classes.Sort("Sort");
            //  dgPVGrid.DataSource = classes;
            using (HyperComponents.Data.dbAccess.Database dbObj = Utils.GetMainDB())
            {
                //using (ds = dbObj.RunSQLReturnDataSet("SELECT * From CountryApprovalTrigger WHERE CountryCode = @CountryCode", HyperComponents.Data.dbAccess.Database.NewSqlParameter("@CountryCode", System.Data.SqlDbType.NVarChar, 50, countryCode)))
                //{
                string sql = "select I.ItemId as ClassId, dbo.GetItemName(I.ItemId) as [PRODUCT TYPE NAME] from  Items I where I.LevelId = 1    ";
                //sql += "SELECT * From CountryApprovalTrigger WHERE CountryCode = '" + countryCode + "'";
                sql += "SELECT W.ItemId AS ClassId, W.PLCode AS PLCode, W.PLCode +' [' + BP.PLName + ']' AS ProductLine, CA.PassiveApprovalDay as [Trigger],CA.ActiveApproval as IsActive FROM Work_Item_ProductLines W ";
                sql += "INNER JOIN Items I ON I.ItemId = W.ItemId AND I.LevelId = 1 ";
                sql += "LEFT OUTER JOIN [CountryApprovalTrigger] CA ON CA.ClassId = W.ItemId AND CA.PLCode = W.PLCode AND CA.CountryCode = '" + countryCode + "' ";
                sql += "INNER JOIN BPL BP ON BP.PLCode = W.PLCode";

                //using (ds = dbObj.RunSQLReturnDataSet(sql.ToString()))
                //{
                //dbObj.CloseConnection();
                ds = dbObj.RunSQLReturnDataSet(sql.ToString());
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataColumn   parentColumn;
                    DataColumn   childColumn;
                    DataRelation relation;
                    parentColumn = ds.Tables[0].Columns["ClassId"];

                    childColumn = ds.Tables[1].Columns["ClassId"];


                    relation = new System.Data.DataRelation("ClassId", parentColumn, childColumn);
                    ds.Relations.Add(relation);
                }
            }
            if (currentCountry != null)
            {
                Debug.Trace("<br>txtCountryNameValue.Text=" + currentCountry.Name + ", txtRegionCodeValue.SelectedValue = " + currentCountry.RegionCode, DebugSeverity.Low);

                txtCountryNameValue.Text         = currentCountry.Name;
                txtCountryCodeValue.Text         = currentCountry.Code;
                cbEditContent.Checked            = currentCountry.CanLocalizeContent;
                cbEditCP.Checked                 = currentCountry.CanCreateProductInLocalLanguage;
                cbEditPLC.Checked                = currentCountry.CanLocalizePLC;
                cbEditMS.Checked                 = currentCountry.CanLocalizeMarketSegments;
                cbEditCS.Checked                 = currentCountry.CanLocalizeCrossSells;
                cbEditPublishers.Checked         = currentCountry.CanLocalizePublishers;
                cbTranslationPLC.Checked         = currentCountry.PLCDrivenTranslation;
                cbIsActive.Checked               = currentCountry.IsActive;
                cbPublishable.Checked            = currentCountry.Publishable;
                cbFallBackToEnglish.Checked      = currentCountry.FallBackToEnglish;
                txtRegionCodeValue.SelectedValue = currentCountry.RegionCode;
                _countries = Business.Region.GetByKey(currentCountry.RegionCode).Countries;
                txtCountryCodeValue.Enabled = false;

                UITools.ShowToolBarButton(propertiesToolBar, "Delete");
                UITools.ShowToolBarSeparator(propertiesToolBar, "DeleteSep");
            }
            else
            {
                cbIsActive.Checked       = true;
                txtCountryNameValue.Text = null;
                txtCountryCodeValue.Text = null;
                UITools.HideToolBarButton(propertiesToolBar, "Delete");
                UITools.HideToolBarSeparator(propertiesToolBar, "DeleteSep");
                if (regionList.SelectedValue != string.Empty)
                {
                    txtRegionCodeValue.SelectedValue = regionList.SelectedValue;
                }
                txtCountryCodeValue.Enabled = true;
            }
            dgPVGrid.DataSource = ds.Tables[0].DefaultView;
            //dgPVGrid.DataSource = ds;
            dgPVGrid.DataBind();
            dgPVGrid.Height = Unit.Empty;
            dgPVGrid.Width  = Unit.Empty;
            Utils.InitGridSort(ref dgPVGrid, false);
            foreach (UltraGridColumn use1 in dgPVGrid.Bands[1].Columns)
            {
                Response.Write(use1.Header.Title);
            }
            //}
            dgPVGrid.Bands[0].Columns[2].Hidden = true;
            dgPVGrid.Bands[1].Columns[5].Hidden = true;
            setPropertiesVisible(true);
        }
Esempio n. 3
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>");
                }
            }
        }