protected void lvCMNDashboardItem_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 DashboardItemID;

            Int64.TryParse(e.CommandArgument.ToString(), out DashboardItemID);

            if (DashboardItemID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _DashboardItemID = DashboardItemID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMNDashboardItemEntity.FLD_NAME_DashboardItemID, DashboardItemID.ToString(), SQLMatchType.Equal);

                        CMNDashboardItemEntity cMNDashboardItemEntity = FCCCMNDashboardItem.GetFacadeCreate().GetByID(DashboardItemID);


                        result = FCCCMNDashboardItem.GetFacadeCreate().Delete(cMNDashboardItemEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            if (File.Exists(Server.MapPath(cMNDashboardItemEntity.ImageUrl)))
                            {
                                File.Delete(Server.MapPath(cMNDashboardItemEntity.ImageUrl));
                            }
                            if (File.Exists(Server.MapPath(cMNDashboardItemEntity.HoverImageUrl)))
                            {
                                File.Delete(Server.MapPath(cMNDashboardItemEntity.HoverImageUrl));
                            }
                            _DashboardItemID        = 0;
                            _CMNDashboardItemEntity = new CMNDashboardItemEntity();

                            PrepareInitialView();
                            BindCMNDashboardItemList();

                            MiscUtil.ShowMessage(lblMessage, "Dashboard Item has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Dashboard Item.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        public IList <CMNDashboardItemEntity> GetPagedData(Int32 startRowIndex, Int32 pageSize, String sortExpression)
        {
            IList <CMNDashboardItemEntity> cMNDashboardItemEntityList = new List <CMNDashboardItemEntity>();

            try
            {
                if (pageSize == -1)
                {
                    pageSize = 1000000000;
                }

                if (String.IsNullOrEmpty(sortExpression))
                {
                    sortExpression = CMNDashboardItemEntity.FLD_NAME_DashboardItemID + " " + SQLConstants.SORT_ORDER_ASCENDING;
                }

                startRowIndex = Convert.ToInt32(startRowIndex / pageSize) + 1;

                cMNDashboardItemEntityList = FCCCMNDashboardItem.GetFacadeCreate().GetIL(startRowIndex, pageSize, sortExpression, null, DatabaseOperationType.LoadPagedWithSortExpression);

                if (cMNDashboardItemEntityList != null && cMNDashboardItemEntityList.Count > 0)
                {
                    totalRowCount = cMNDashboardItemEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(cMNDashboardItemEntityList ?? new List <CMNDashboardItemEntity>());
        }
        private void SaveCMNDashboardItemEntity()
        {
            if (IsValid)
            {
                try
                {
                    CMNDashboardItemEntity cMNDashboardItemEntity = BuildCMNDashboardItemEntity();

                    Int64 result = -1;

                    if (cMNDashboardItemEntity.IsNew)
                    {
                        result = FCCCMNDashboardItem.GetFacadeCreate().Add(cMNDashboardItemEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(CMNDashboardItemEntity.FLD_NAME_DashboardItemID, cMNDashboardItemEntity.DashboardItemID.ToString(), SQLMatchType.Equal);
                        result = FCCCMNDashboardItem.GetFacadeCreate().Update(cMNDashboardItemEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _DashboardItemID        = 0;
                        _CMNDashboardItemEntity = new CMNDashboardItemEntity();
                        PrepareInitialView();
                        BindCMNDashboardItemList();

                        if (cMNDashboardItemEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Dashboard Item Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Dashboard Item Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (cMNDashboardItemEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Dashboard Item Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Dashboard Item Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
Exemplo n.º 4
0
        protected void lvCMNDashboardItem_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 DashboardItemID;

            Int64.TryParse(e.CommandArgument.ToString(), out DashboardItemID);

            if (DashboardItemID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _DashboardItemID = DashboardItemID;

                    PrepareEditView();
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMNDashboardItemEntity.FLD_NAME_DashboardItemID, DashboardItemID.ToString(), SQLMatchType.Equal);

                        CMNDashboardItemEntity cMNDashboardItemEntity = FCCCMNDashboardItem.GetFacadeCreate().GetByID(DashboardItemID);


                        result = FCCCMNDashboardItem.GetFacadeCreate().Delete(cMNDashboardItemEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            if (File.Exists(Server.MapPath(cMNDashboardItemEntity.ImageUrl)))
                            {
                                File.Delete(Server.MapPath(cMNDashboardItemEntity.ImageUrl));
                            }
                            if (File.Exists(Server.MapPath(cMNDashboardItemEntity.HoverImageUrl)))
                            {
                                File.Delete(Server.MapPath(cMNDashboardItemEntity.HoverImageUrl));
                            }
                            _DashboardItemID        = 0;
                            _CMNDashboardItemEntity = new CMNDashboardItemEntity();

                            PrepareInitialView();
                        }
                        else
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
        public IList <CMNDashboardItemEntity> GetData()
        {
            IList <CMNDashboardItemEntity> cMNDashboardItemEntityList = new List <CMNDashboardItemEntity>();

            try
            {
                cMNDashboardItemEntityList = FCCCMNDashboardItem.GetFacadeCreate().GetIL(null, null, null, null, DatabaseOperationType.Load);

                if (cMNDashboardItemEntityList != null && cMNDashboardItemEntityList.Count > 0)
                {
                    totalRowCount = cMNDashboardItemEntityList[0].TotalRowCount;
                }
            }
            catch (Exception ex)
            {
            }

            return(cMNDashboardItemEntityList ?? new List <CMNDashboardItemEntity>());
        }
        private void GetMaxSequenceID()
        {
            String fe            = String.Empty;
            Int64  MaxSequenceID = 0;
            IList <CMNDashboardItemEntity> DashboardItemList = new List <CMNDashboardItemEntity>();

            if (_DashboardItemID > 0)
            {
                rfvImageUrl.Enabled = false;
            }
            if (ddlParentDashboardItemID.SelectedValue != "0")
            {
                fe = SqlExpressionBuilder.PrepareFilterExpression(CMNDashboardItemEntity.FLD_NAME_ParentDashboardItemID, ddlParentDashboardItemID.SelectedValue, SQLMatchType.Equal);
                DashboardItemList = FCCCMNDashboardItem.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);
                if (DashboardItemList != null && DashboardItemList.Count > 0)
                {
                    Int64.TryParse(DashboardItemList[DashboardItemList.Count - 1].SequenceID.ToString(), out MaxSequenceID);
                }
            }

            if (ddlParentDashboardItemID.SelectedValue == "0")
            {
                fe = SqlExpressionBuilder.PrepareFilterExpression(CMNDashboardItemEntity.FLD_NAME_ParentDashboardItemID, String.Empty, SQLMatchType.IsNull);
                DashboardItemList = FCCCMNDashboardItem.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);
                if (DashboardItemList != null && DashboardItemList.Count > 0)
                {
                    Int64.TryParse(DashboardItemList[DashboardItemList.Count - 1].SequenceID.ToString(), out MaxSequenceID);
                }
            }

            txtSequenceID.Text = (MaxSequenceID + 1).ToString();

            #region Only Display region

            if (_DashboardItemID > 0 && ddlParentDashboardItemID.SelectedValue == CurrentCMNDashboardItemEntity.ParentDashboardItemID.ToString())
            {
                txtSequenceID.Text = CurrentCMNDashboardItemEntity.SequenceID.ToString();
            }

            #endregion
        }