private void Duplicate(HyperCatalog.Business.ChunkStatus status)
        {
            if (dg != null)
            {
                string sChunks       = string.Empty;
                string containerList = string.Empty;
                bool   isSelected    = false;

                TemplatedColumn col = (TemplatedColumn)dg.Columns.FromKey("Select");
                ((CheckBox)(col.HeaderItem.FindControl("g_ca"))).Checked = false;

                int currentIndex = -1;
                for (int i = 0; i < col.CellItems.Count; i++)
                {
                    currentIndex = ((CellItem)col.CellItems[i]).Cell.Row.Index;
                    CheckBox cb = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd");
                    if (cb.Checked)
                    {
                        if (sChunks.Length > 0)
                        {
                            sChunks       += "|";
                            containerList += ",";
                        }
                        sChunks += dg.Rows[currentIndex].Cells.FromKey("ItemId").Value.ToString();
                        sChunks += ",";
                        sChunks += dg.Rows[currentIndex].Cells.FromKey("ContainerId").Value.ToString();
                        sChunks += ",";
                        sChunks += "'" + dg.Rows[currentIndex].Cells.FromKey("SourceCode").Value.ToString() + "'";

                        containerList += dg.Rows[currentIndex].Cells.FromKey("ContainerId").Value.ToString();
                    }
                }

                if (sChunks.Length > 0)
                {
                    if (!_Item.Regionalize(SessionState.Culture.Code, SessionState.User.Id, sChunks, status))
                    {
                        lbError.Visible = false;
                        lbError.Text    = Item.LastError;
                        lbError.Visible = true;
                    }
                    else
                    {
                        if (containerList.Length > 0)
                        {
                            // Force translation to draft
                            if (!_Item.ForceTranslationsToDraft(SessionState.Culture.Code, containerList, SessionState.User.Id))
                            {
                                lbError.Visible = false;
                                lbError.Text    = Item.LastError;
                                lbError.Visible = true;
                                return;
                            }
                        }
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Update grid", "<script>UpdateGrid(" + _Item.Id.ToString() + "," + _InputformId.ToString() + ",\"" + SessionState.Culture.Code + "\");</script>");
                    }
                }
                UpdateDataView();
            }
        }
        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>");
                }
            }
        }