Ejemplo n.º 1
0
        private static string CreateOrUpdate(SystemForeignRelationshipDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

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

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.FieldName) +
                  ", " + ToSQLParameter(data, SystemForeignRelationshipDataModel.DataColumns.Source);
            return(sql);
        }
Ejemplo n.º 2
0
        protected override void ShowData(int systemForeignRelationshipId)
        {
            base.ShowData(systemForeignRelationshipId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new SystemForeignRelationshipDataModel();

            data.SystemForeignRelationshipId = systemForeignRelationshipId;

            var items = Framework.Components.Core.SystemForeignRelationshipDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            // should only have single match
            if (items.Count == 1)
            {
                var item = items[0];

                lblSystemForeignRelationshipId.Text = item.SystemForeignRelationshipId.ToString();
                lblPrimaryDatabase.Text             = item.PrimaryDatabase;
                lblPrimaryEntityId.Text             = item.PrimaryEntity;
                lblForeignDatabase.Text             = item.ForeignDatabase;
                lblForeignEntityId.Text             = item.ForeignEntity;
                lblFieldName.Text = item.FieldName;
                lblSource.Text    = item.Source;
                lblSystemForeignRelationshipType.Text = item.SystemForeignRelationshipType;

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

                oHistoryList.Setup(PrimaryEntity, systemForeignRelationshipId, "SystemForeignRelationship");
            }
        }
Ejemplo n.º 3
0
        public override int?Save(string action)
        {
            var data = new SystemForeignRelationshipDataModel();

            data.SystemForeignRelationshipId = SystemForeignRelationshipId;
            data.PrimaryEntityId             = PrimaryEntityId;
            data.PrimaryDatabaseId           = PrimaryDatabaseId;
            data.ForeignDatabaseId           = ForeignDatabaseId;
            data.ForeignEntityId             = ForeignEntityId;
            data.FieldName = FieldName;
            data.Source    = Source;
            data.SystemForeignRelationshipTypeId = SystemForeignRelationshipTypeId;

            if (action == "Insert")
            {
                Framework.Components.Core.SystemForeignRelationshipDataManager.Create(data, SessionVariables.RequestProfile);
            }
            else
            {
                Framework.Components.Core.SystemForeignRelationshipDataManager.Update(data, SessionVariables.RequestProfile);
            }

            // not correct ... when doing insert, we didn't get/change the value of ApplicationRouteID ?
            return(data.SystemForeignRelationshipId);
        }
Ejemplo n.º 4
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new SystemForeignRelationshipDataModel();

            UpdatedData = Framework.Components.Core.SystemForeignRelationshipDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.SystemForeignRelationshipId =
                    Convert.ToInt32(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipId].ToString());

                data.PrimaryDatabaseId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId))
                                        : int.Parse(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId].ToString());

                data.ForeignDatabaseId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId))
                                        : int.Parse(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId].ToString());

                data.PrimaryEntityId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId).ToString())
                                        : int.Parse(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId].ToString());

                data.ForeignEntityId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId).ToString())
                                        : int.Parse(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId].ToString());

                data.FieldName =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.FieldName))
                                        ? CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.FieldName).ToString()
                                        : SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.FieldName].ToString();

                data.Source =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.Source))
                                        ? CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.Source).ToString()
                                        : SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.Source].ToString();

                data.SystemForeignRelationshipTypeId =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId).ToString())
                                        : int.Parse(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId].ToString());

                Framework.Components.Core.SystemForeignRelationshipDataManager.Update(data, SessionVariables.RequestProfile);
                data = new SystemForeignRelationshipDataModel();

                data.SystemForeignRelationshipId = Convert.ToInt32(SelectedData.Rows[i][SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipId].ToString());
                var dt = Framework.Components.Core.SystemForeignRelationshipDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Ejemplo n.º 5
0
        public static DataTable DoesExist(SystemForeignRelationshipDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new SystemForeignRelationshipDataModel();

            doesExistRequest.PrimaryEntityId = data.PrimaryEntityId;

            return(Search(doesExistRequest, requestProfile));
        }
Ejemplo n.º 6
0
        public static DataTable Search(SystemForeignRelationshipDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            var table = list.ToDataTable();

            return(table);
        }
Ejemplo n.º 7
0
        private DataTable GetData(string name)
        {
            var data = new SystemForeignRelationshipDataModel();

            data.PrimaryDatabase = name;
            var dt = Framework.Components.Core.SystemForeignRelationshipDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Ejemplo n.º 8
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var systemForeignRelationshipdata = new SystemForeignRelationshipDataModel();

            systemForeignRelationshipdata.SystemForeignRelationshipId = entityKey;
            var results = Framework.Components.Core.SystemForeignRelationshipDataManager.Search(systemForeignRelationshipdata, SessionVariables.RequestProfile);

            return(results);
        }
Ejemplo n.º 9
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new SystemForeignRelationshipDataModel();

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

            Framework.Components.Core.SystemForeignRelationshipDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
Ejemplo n.º 10
0
        public static bool DoesExist(SystemForeignRelationshipDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new SystemForeignRelationshipDataModel();

            doesExistRequest.PrimaryEntityId = data.PrimaryEntityId;

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

            return(list.Count > 0);
        }
Ejemplo n.º 11
0
        protected override void Clear()
        {
            base.Clear();

            var data = new SystemForeignRelationshipDataModel();

            SystemForeignRelationshipId = data.SystemForeignRelationshipId;
            PrimaryDatabaseId           = data.PrimaryDatabaseId;
            PrimaryEntityId             = data.PrimaryEntityId;
            ForeignDatabaseId           = data.ForeignDatabaseId;
            ForeignEntityId             = data.ForeignEntityId;
            Source = data.Source;
        }
Ejemplo n.º 12
0
        public static void Delete(SystemForeignRelationshipDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.SystemForeignRelationshipDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                , SystemForeignRelationshipId = dataQuery.SystemForeignRelationshipId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Ejemplo n.º 13
0
        public void LoadData(int systemForeignRelationshipId, bool showId)
        {
            // clear UI
            Clear();

            // set up parameters
            var data = new SystemForeignRelationshipDataModel();

            data.SystemForeignRelationshipId = systemForeignRelationshipId;

            // get data
            var items = Framework.Components.Core.SystemForeignRelationshipDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

            // should only have single match -- should log exception.
            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            SystemForeignRelationshipId = item.SystemForeignRelationshipId;
            PrimaryDatabaseId           = item.PrimaryDatabaseId;
            PrimaryEntityId             = item.PrimaryEntityId;
            ForeignDatabaseId           = item.ForeignDatabaseId;
            ForeignEntityId             = item.ForeignEntityId;
            FieldName = item.FieldName;
            Source    = item.Source;
            SystemForeignRelationshipTypeId = item.SystemForeignRelationshipTypeId;

            if (!showId)
            {
                txtSystemForeignRelationshipId.Text = item.SystemForeignRelationshipId.ToString();

                //PlaceHolderAuditHistory.Visible = true;
                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup(PrimaryEntity, systemForeignRelationshipId, PrimaryEntityKey);
            }
            else
            {
                txtSystemForeignRelationshipId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
Ejemplo n.º 14
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string[] deleteIndexList = DeleteIds.Split(',');
                foreach (string index in deleteIndexList)
                {
                    var data = new SystemForeignRelationshipDataModel();
                    data.SystemForeignRelationshipId = int.Parse(index);
                    Framework.Components.Core.SystemForeignRelationshipDataManager.Delete(data, SessionVariables.RequestProfile);
                }

                Framework.Components.Audit.AuditHistoryDataManager.DeleteDataBySystemEntity(DeleteIds, (int)Framework.Components.DataAccess.SystemEntity.SystemForeignRelationship, SessionVariables.RequestProfile);
                Response.Redirect(Page.GetRouteUrl("SystemForeignRelationshipEntityRoute", new { Action = "Default", SetId = true }), false);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 15
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var systemForeignRelationshipdata = new SystemForeignRelationshipDataModel();

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

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

            return(null);
        }
Ejemplo n.º 16
0
        public static List <SystemForeignRelationshipDataModel> GetEntityDetails(SystemForeignRelationshipDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.SystemForeignRelationshipSearch ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                , SystemForeignRelationshipId = dataQuery.SystemForeignRelationshipId
                , ForeignDatabaseId           = dataQuery.ForeignDatabaseId
                , PrimaryDatabaseId           = dataQuery.PrimaryDatabaseId
            };

            List <SystemForeignRelationshipDataModel> result;

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


            return(result);
        }
Ejemplo n.º 17
0
        public static void Update(SystemForeignRelationshipDataModel data, RequestProfile requestProfile)
        {
            var sql = CreateOrUpdate(data, requestProfile, "Update");

            DBDML.RunSQL("SystemForeignRelationship.Update", sql, DataStoreKey);
        }
Ejemplo n.º 18
0
        public static SystemForeignRelationshipDataModel GetDetails(SystemForeignRelationshipDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Ejemplo n.º 19
0
        public static string ToSQLParameter(SystemForeignRelationshipDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

            case SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId:
                if (data.PrimaryDatabaseId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId, data.PrimaryDatabaseId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabaseId);
                }
                break;


            case SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabase:
                if (!string.IsNullOrEmpty(data.PrimaryDatabase))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabase, data.PrimaryDatabase.Trim());
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.PrimaryDatabase);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId:
                if (data.PrimaryEntityId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId, data.PrimaryEntityId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.PrimaryEntityId);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.ForeignDatabase:
                if (!string.IsNullOrEmpty(data.ForeignDatabase))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SystemForeignRelationshipDataModel.DataColumns.ForeignDatabase, data.ForeignDatabase.Trim());
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.ForeignDatabase);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId:
                if (data.ForeignDatabaseId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId, data.ForeignDatabaseId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.ForeignDatabaseId);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId:
                if (data.ForeignEntityId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId, data.ForeignEntityId);
                }
                else
                {
                    returnValue = returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.ForeignEntityId);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId:
                if (data.SystemForeignRelationshipTypeId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId, data.SystemForeignRelationshipTypeId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipTypeId);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipType:
                if (!string.IsNullOrEmpty(data.SystemForeignRelationshipType))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipType, data.SystemForeignRelationshipType);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.SystemForeignRelationshipType);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.FieldName:
                if (!string.IsNullOrEmpty(data.FieldName))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SystemForeignRelationshipDataModel.DataColumns.FieldName, data.FieldName);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.FieldName);
                }
                break;

            case SystemForeignRelationshipDataModel.DataColumns.Source:
                if (!string.IsNullOrEmpty(data.Source))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, SystemForeignRelationshipDataModel.DataColumns.Source, data.Source);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, SystemForeignRelationshipDataModel.DataColumns.Source);
                }
                break;

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