Esempio n. 1
0
        protected override void ShowData(int menuCategoryId)
        {
            oDetailButtonPanel.SetId = SetId;
            var data = new MenuCategoryDataModel();

            data.MenuCategoryId = menuCategoryId;

            var items = MenuCategoryDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count == 1)
            {
                var item = items[0];

                lblMenuCategoryId.Text = item.MenuCategoryId.ToString();
                lblName.Text           = item.Name.ToString();
                lblDescription.Text    = item.Description.ToString();
                lblSortOrder.Text      = item.SortOrder.ToString();

                oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);

                oHistoryList.Setup(PrimaryEntity, menuCategoryId, "MenuCategoryId");
            }
            else
            {
                Clear();
            }
        }
Esempio n. 2
0
        public static int Create(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("MenuCategory.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Esempio n. 3
0
        public static string Save(MenuCategoryDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            switch (action)
            {
            case "Create":
                sql += "dbo.MenuCategoryInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.MenuCategoryUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, MenuCategoryDataModel.DataColumns.MenuCategoryId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);

            return(sql);
        }
Esempio n. 4
0
        public void LoadData(int menuCategoryId, bool showId)
        {
            Clear();

            var data = new MenuCategoryDataModel();

            data.MenuCategoryId = menuCategoryId;

            var items = MenuCategoryDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            SetData(item);

            if (!showId)
            {
                SystemKeyId = item.MenuCategoryId;
                oHistoryList.Setup(PrimaryEntity, menuCategoryId, PrimaryEntityKey);
            }
            else
            {
                CoreSystemKey.Text = String.Empty;
            }
        }
Esempio n. 5
0
        public override int?Save(string action)
        {
            var data = new MenuCategoryDataModel();

            data.MenuCategoryId = SystemKeyId;
            data.Name           = Name;
            data.Description    = Description;
            data.SortOrder      = SortOrder;

            if (action == "Insert")
            {
                var dtMenuCategory = MenuCategoryDataManager.DoesExist(data, SessionVariables.RequestProfile);

                if (dtMenuCategory.Rows.Count == 0)
                {
                    MenuCategoryDataManager.Create(data, SessionVariables.RequestProfile);
                }
                else
                {
                    throw new Exception("Record with given ID already exists.");
                }
            }
            else
            {
                MenuCategoryDataManager.Update(data, SessionVariables.RequestProfile);
            }

            return(data.MenuCategoryId);
        }
Esempio n. 6
0
        public static DataTable DoesExist(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new MenuCategoryDataModel();

            doesExistRequest.Name = data.Name;
            return(Search(doesExistRequest, requestProfile));
        }
Esempio n. 7
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new MenuCategoryDataModel();

            UpdatedData = Framework.Components.Core.MenuCategoryDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.MenuCategoryId =
                    Convert.ToInt32(SelectedData.Rows[i][MenuCategoryDataModel.DataColumns.MenuCategoryId].ToString());
                data.Name        = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString();
                data.Description =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description))
                                        ? CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description)
                                        : SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString();

                data.SortOrder =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder).ToString())
                                        : int.Parse(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString());

                Framework.Components.Core.MenuCategoryDataManager.Update(data, SessionVariables.RequestProfile);
                data = new MenuCategoryDataModel();
                data.MenuCategoryId = Convert.ToInt32(SelectedData.Rows[i][MenuCategoryDataModel.DataColumns.MenuCategoryId].ToString());
                var dt = Framework.Components.Core.MenuCategoryDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Esempio n. 8
0
        public static void Sync(int newApplicationId, int oldApplicationId, RequestProfile requestProfile)
        {
            // get all records for old Application Id
            var sql = "EXEC dbo.MenuCategorySearch " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, oldApplicationId);

            var oDT = new DBDataTable("MenuCategory.Search", sql, DataStoreKey);

            // formaulate a new request Profile which will have new Applicationid
            var newRequestProfile = new RequestProfile();

            newRequestProfile.ApplicationId = newApplicationId;
            newRequestProfile.AuditId       = requestProfile.AuditId;

            foreach (DataRow dr in oDT.DBTable.Rows)
            {
                var data = new MenuCategoryDataModel();
                data.ApplicationId = newApplicationId;
                data.Name          = dr[MenuCategoryDataModel.DataColumns.Name].ToString();

                // check for existing record in new Application Id
                if (!DoesExist(data, newRequestProfile))
                {
                    data.Description = dr[MenuCategoryDataModel.DataColumns.Description].ToString();
                    data.SortOrder   = Convert.ToInt32(dr[MenuCategoryDataModel.DataColumns.SortOrder]);

                    //create in new application id
                    Create(data, newRequestProfile);
                }
            }
        }
Esempio n. 9
0
        public void Delete(string value)
        {
            var dataQuery = new MenuCategoryDataModel();

            dataQuery.MenuCategoryId = int.Parse(value);
            MenuCategoryDataManager.Delete(dataQuery, SessionVariables.RequestProfile);
        }
Esempio n. 10
0
        protected override void Clear()
        {
            base.Clear();

            var data = new MenuCategoryDataModel();

            SetData(data);
        }
Esempio n. 11
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var notDeletableIds = new List <int>();
                var deleteIndexList = DeleteIds.Split(',');

                foreach (var index in deleteIndexList)
                {
                    var data = new MenuCategoryDataModel();
                    data.MenuCategoryId = int.Parse(index);

                    if (!MenuCategoryDataManager.IsDeletable(data, SessionVariables.RequestProfile))
                    {
                        notDeletableIds.Add((int)(data.MenuCategoryId));
                    }
                }

                if (notDeletableIds.Count == 0)
                {
                    foreach (var index in deleteIndexList)
                    {
                        var data = new MenuCategoryDataModel();
                        data.MenuCategoryId = int.Parse(index);

                        MenuCategoryDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }
                else
                {
                    var msg = String.Empty;

                    foreach (var id in notDeletableIds)
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            msg += ", <br/>";
                        }
                        msg += "MenuCategoryId: " + id + " has detail records";
                    }

                    foreach (string index in deleteIndexList)
                    {
                        var data = new MenuCategoryDataModel();
                        data.MenuCategoryId = int.Parse(index);

                        MenuCategoryDataManager.DeleteChildren(data, SessionVariables.RequestProfile);
                        MenuCategoryDataManager.Delete(data, SessionVariables.RequestProfile);
                    }
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Esempio n. 12
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var menuCategorydata = new MenuCategoryDataModel();

            menuCategorydata.MenuCategoryId = entityKey;
            var results = Framework.Components.Core.MenuCategoryDataManager.Search(menuCategorydata, SessionVariables.RequestProfile);

            return(results);
        }
Esempio n. 13
0
        public static DataSet GetChildren(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.MenuCategoryChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, MenuCategoryDataModel.DataColumns.MenuCategoryId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Esempio n. 14
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new MenuCategoryDataModel();

            var dt = Framework.Components.Core.MenuCategoryDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Esempio n. 15
0
        public static DataSet DeleteChildren(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.MenuCategoryChildrenDelete " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, MenuCategoryDataModel.DataColumns.MenuCategoryId);

            var oDt = new DBDataSet("MenuCategory.DeleteChildren", sql, DataStoreKey);

            return(oDt.DBDataset);
        }
Esempio n. 16
0
        public MenuCategoryDataModel GetById(string value)
        {
            var dataQuery = new MenuCategoryDataModel();

            dataQuery.MenuCategoryId = int.Parse(value);

            var result = MenuCategoryDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

            return(result[0]);
        }
Esempio n. 17
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new MenuCategoryDataModel();

            // copies properties from values dictionary object to data object
            PropertyMapper.CopyProperties(data, values);

            Framework.Components.Core.MenuCategoryDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
Esempio n. 18
0
        private DataTable GetData(string name)
        {
            var data = new MenuCategoryDataModel();

            data.Name = name;

            var dt = MenuCategoryDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Esempio n. 19
0
        public static bool DoesExist(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new MenuCategoryDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Esempio n. 20
0
        public static void Delete(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.MenuCategoryDelete ";

            var parameters =
                new
            {
                AuditId          = requestProfile.AuditId
                , MenuCategoryId = data.MenuCategoryId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Esempio n. 21
0
        public static bool IsDeletable(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var isDeletable = true;
            var ds          = GetChildren(data, requestProfile);

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataTable dt in ds.Tables)
                {
                    if (dt.Rows.Count > 0)
                    {
                        isDeletable = false;
                        break;
                    }
                }
            }
            return(isDeletable);
        }
Esempio n. 22
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows     = new DataTable();
                var menuCategorydata = new MenuCategoryDataModel();

                selectedrows = Framework.Components.Core.MenuCategoryDataManager.GetDetails(menuCategorydata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        menuCategorydata.MenuCategoryId = entityKey;
                        var result = Framework.Components.Core.MenuCategoryDataManager.GetDetails(menuCategorydata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    menuCategorydata.MenuCategoryId = SetId;
                    var result = Framework.Components.Core.MenuCategoryDataManager.GetDetails(menuCategorydata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(null);
        }
Esempio n. 23
0
        public static List <MenuCategoryDataModel> GetEntityDetails(MenuCategoryDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.MenuCategorySearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ApplicationMode = requestProfile.ApplicationModeId
                , ReturnAuditInfo = returnAuditInfo
                , MenuCategoryId  = dataQuery.MenuCategoryId
                , Name            = dataQuery.Name
            };

            List <MenuCategoryDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <MenuCategoryDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Esempio n. 24
0
        public static string ToSQLParameter(MenuCategoryDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case MenuCategoryDataModel.DataColumns.MenuCategoryId:
                if (data.MenuCategoryId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, MenuCategoryDataModel.DataColumns.MenuCategoryId, data.MenuCategoryId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, MenuCategoryDataModel.DataColumns.MenuCategoryId);
                }
                break;

            default:
                returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Esempio n. 25
0
        public static MenuCategoryDataModel GetDetails(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Esempio n. 26
0
 public void Update([FromBody] MenuCategoryDataModel data)
 {
     MenuCategoryDataManager.Update(data, SessionVariables.RequestProfile);
 }
Esempio n. 27
0
        public static DataTable Search(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Esempio n. 28
0
        public static void SyncModule(string newModule, int newApplicationId,
                                      string sourceModule, int sourceApplicationId, RequestProfile requestProfile)
        {
            var sourceRequestProfile = new RequestProfile();

            sourceRequestProfile.ApplicationId = sourceApplicationId;
            sourceRequestProfile.AuditId       = requestProfile.AuditId;

            var newRequestProfile = new RequestProfile();

            newRequestProfile.ApplicationId = newApplicationId;
            newRequestProfile.AuditId       = requestProfile.AuditId;

            // get Language id of "Standard"
            var languageData = new LanguageDataModel();

            languageData.Name = "English";

            var languageRecords = LanguageDataManager.GetEntityDetails(languageData, newRequestProfile, 0);

            if (languageRecords.Count > 0)
            {
                DeleteHardExistingRecords(newModule, newRequestProfile);

                var languageId = languageRecords[0].LanguageId.Value;

                var dataQuery = new MenuDataModel();
                dataQuery.ApplicationModule = sourceModule;
                dataQuery.ApplicationId     = sourceApplicationId;

                var dataSourceMenu = MenuDataManager.GetEntityDetails(dataQuery, sourceRequestProfile, 0);

                var menuDisplayNameData = new MenuDisplayNameDataModel();
                var menuDisplayNameList = MenuDisplayNameDataManager.GetEntityDetails(menuDisplayNameData, sourceRequestProfile);

                var sortOrderSeed = 101;

                var listSourceRecords = dataSourceMenu
                                        .Where(t => t.ParentMenuId == null)
                                        .Select(t => t)
                                        .OrderBy(t => t.SortOrder).ToList();

                if (listSourceRecords.Count > 0)
                {
                    foreach (MenuDataModel menuSourceRecord in listSourceRecords)
                    {
                        var menuModel = new MenuDataModel();

                        menuModel.Name             = menuSourceRecord.Name;
                        menuModel.Value            = menuSourceRecord.Value;
                        menuModel.Description      = menuSourceRecord.Description;
                        menuModel.IsVisible        = menuSourceRecord.IsVisible;
                        menuModel.IsChecked        = menuSourceRecord.IsChecked;
                        menuModel.ParentMenuId     = menuSourceRecord.ParentMenuId;
                        menuModel.PrimaryDeveloper = menuSourceRecord.PrimaryDeveloper;
                        menuModel.NavigateURL      = menuSourceRecord.NavigateURL;

                        menuModel.ApplicationId     = newApplicationId;
                        menuModel.ApplicationModule = newModule;
                        menuModel.SortOrder         = sortOrderSeed;

                        if (!DoesExist(menuModel, newRequestProfile))
                        {
                            var newMenuId = MenuDataManager.Create(menuModel, newRequestProfile);

                            var menuDisplayNameValue = menuModel.Value;

                            try
                            {
                                menuDisplayNameValue = menuDisplayNameList.Find(x => x.MenuId == menuSourceRecord.MenuId && x.IsDefault == 1).Value;
                            }
                            catch { }

                            var dataDisplayName = new MenuDisplayNameDataModel();
                            dataDisplayName.MenuId     = newMenuId;
                            dataDisplayName.Value      = menuDisplayNameValue;
                            dataDisplayName.LanguageId = languageId;
                            dataDisplayName.IsDefault  = 1;

                            // create display name entry according to the default display name
                            MenuDisplayNameDataManager.Create(dataDisplayName, newRequestProfile);

                            sortOrderSeed++;

                            var childMenuRecordsList = dataSourceMenu
                                                       .Where(t => t.ParentMenuId == menuSourceRecord.MenuId)
                                                       .Select(t => t)
                                                       .OrderBy(t => t.SortOrder).ToList();

                            CreateChildMenuRecords(newMenuId, newModule,
                                                   childMenuRecordsList, dataSourceMenu, menuDisplayNameList,
                                                   languageId, newRequestProfile);
                        }
                    }

                    // get menu category id of "Standard"
                    var menuCategoryData = new MenuCategoryDataModel();
                    menuCategoryData.Name = "Standard";

                    var menuCategoryRecords = MenuCategoryDataManager.GetEntityDetails(menuCategoryData, newRequestProfile, 0);

                    if (menuCategoryRecords.Count > 0)
                    {
                        var menuCategoryId = menuCategoryRecords[0].MenuCategoryId;

                        // get newly inserted records
                        dataQuery = new MenuDataModel();
                        dataQuery.ApplicationModule = newModule;
                        dataQuery.ApplicationId     = newApplicationId;
                        var newMenuRecords = GetEntityDetails(dataQuery, newRequestProfile);

                        var listMenuIds = newMenuRecords.Select(x => x.MenuId.Value).ToArray();

                        // add MenuCategoryXMenu records
                        MenuCategoryXMenuDataManager.CreateByMenuCategory(menuCategoryId.Value, listMenuIds, newRequestProfile);
                    }
                }
            }
        }
Esempio n. 29
0
        public void SetData(MenuCategoryDataModel data)
        {
            SystemKeyId = data.MenuCategoryId;

            base.SetData(data);
        }
Esempio n. 30
0
        public static void Update(MenuCategoryDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("MenuCategory.Update", sql, DataStoreKey);
        }