Exemplo n.º 1
0
        public static string Save(EntityDateRangeStateTypeDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

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

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

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

            return(sql);
        }
Exemplo n.º 2
0
        public static int Create(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("EntityDateRangeStateType.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Exemplo n.º 3
0
        private void SetupDropdown()
        {
            var isTesting = SessionVariables.IsTesting;
            var data      = new EntityDateRangeStateTypeDataModel();
            var dateRangeStateTypeData = EntityDateRangeStateTypeDataManager.GetDetails(EntityDateRangeStateTypeDataModel.Empty, SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(dateRangeStateTypeData, drpEntityDateRangeStateTypeList, StandardDataModel.StandardDataColumns.Name, EntityDateRangeStateTypeDataModel.DataColumns.EntityDateRangeStateTypeId);

            if (isTesting)
            {
                drpEntityDateRangeStateTypeList.AutoPostBack = true;
                if (drpEntityDateRangeStateTypeList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtEntityDateRangeStateTypeId.Text.Trim()))
                    {
                        drpEntityDateRangeStateTypeList.SelectedValue = txtEntityDateRangeStateTypeId.Text;
                    }
                    else
                    {
                        txtEntityDateRangeStateTypeId.Text = drpEntityDateRangeStateTypeList.SelectedItem.Value;
                    }
                }
                txtEntityDateRangeStateTypeId.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(txtEntityDateRangeStateTypeId.Text.Trim()))
                {
                    drpEntityDateRangeStateTypeList.SelectedValue = txtEntityDateRangeStateTypeId.Text;
                }
            }
        }
Exemplo n.º 4
0
        public override int?Save(string action)
        {
            var data = new EntityDateRangeStateTypeDataModel();

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

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

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

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

            var data = new EntityDateRangeStateTypeDataModel();

            UpdatedData = EntityDateRangeStateTypeDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.EntityDateRangeStateTypeId =
                    Convert.ToInt32(SelectedData.Rows[i][EntityDateRangeStateTypeDataModel.DataColumns.EntityDateRangeStateTypeId].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());

                EntityDateRangeStateTypeDataManager.Update(data, SessionVariables.RequestProfile);
                data = new EntityDateRangeStateTypeDataModel();
                data.EntityDateRangeStateTypeId = Convert.ToInt32(SelectedData.Rows[i][EntityDateRangeStateTypeDataModel.DataColumns.EntityDateRangeStateTypeId].ToString());
                var dt = EntityDateRangeStateTypeDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
Exemplo n.º 6
0
        protected override void Clear()
        {
            base.Clear();

            var data = new EntityDateRangeStateTypeDataModel();

            SetData(data);
        }
Exemplo n.º 7
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var entityDateRangeStateTypedata = new EntityDateRangeStateTypeDataModel();

            entityDateRangeStateTypedata.EntityDateRangeStateTypeId = entityKey;
            var results = EntityDateRangeStateTypeDataManager.Search(entityDateRangeStateTypedata, SessionVariables.RequestProfile);

            return(results);
        }
Exemplo n.º 8
0
        public static DataSet GetChildren(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.EntityDateRangeStateTypeChildrenGet" +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, EntityDateRangeStateTypeDataModel.DataColumns.EntityDateRangeStateTypeId);
            var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Exemplo n.º 9
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new EntityDateRangeStateTypeDataModel();

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

            EntityDateRangeStateTypeDataManager.Update(data, SessionVariables.RequestProfile);
            base.Update(values);
        }
Exemplo n.º 10
0
        public static bool DoesExist(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new EntityDateRangeStateTypeDataModel();

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

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

            return(list.Count > 0);
        }
Exemplo n.º 11
0
        public static void Delete(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.EntityDateRangeStateTypeDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Exemplo n.º 12
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string[] deleteIndexList = DeleteIds.Split(',');
         foreach (string index in deleteIndexList)
         {
             var data = new EntityDateRangeStateTypeDataModel();
             data.EntityDateRangeStateTypeId = int.Parse(index);
             EntityDateRangeStateTypeDataManager.Delete(data, SessionVariables.RequestProfile);
             DeleteAndRedirect();
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Exemplo n.º 13
0
        public static bool IsDeletable(EntityDateRangeStateTypeDataModel 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);
        }
Exemplo n.º 14
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var entityDateRangeStateTypedata = new EntityDateRangeStateTypeDataModel();

                selectedrows = EntityDateRangeStateTypeDataManager.GetDetails(entityDateRangeStateTypedata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        entityDateRangeStateTypedata.EntityDateRangeStateTypeId = entityKey;
                        var result = EntityDateRangeStateTypeDataManager.GetDetails(entityDateRangeStateTypedata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    entityDateRangeStateTypedata.EntityDateRangeStateTypeId = SetId;
                    var result = EntityDateRangeStateTypeDataManager.GetDetails(entityDateRangeStateTypedata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return(null);
        }
Exemplo n.º 15
0
        protected override void ShowData(int entityDateRangeStateTypeId)
        {
            base.ShowData(entityDateRangeStateTypeId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new EntityDateRangeStateTypeDataModel();

            data.EntityDateRangeStateTypeId = entityDateRangeStateTypeId;

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

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

                SetData(item);

                oHistoryList.Setup(PrimaryEntity, entityDateRangeStateTypeId, "EntityDateRangeStateType");
            }
        }
Exemplo n.º 16
0
        public static string ToSQLParameter(EntityDateRangeStateTypeDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

            return(returnValue);
        }
Exemplo n.º 17
0
        public void LoadData(int entityDateRangeStateTypeId, bool showId)
        {
            // clear UI
            Clear();

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

            data.EntityDateRangeStateTypeId = entityDateRangeStateTypeId;

            // get data
            var items = EntityDateRangeStateTypeDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

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

            var item = items[0];

            SetData(item);

            if (!showId)
            {
                SystemKeyId = item.EntityDateRangeStateTypeId;

                //PlaceHolderAuditHistory.Visible = true;
                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup(PrimaryEntity, entityDateRangeStateTypeId, PrimaryEntityKey);
            }
            else
            {
                CoreSystemKey.Text = String.Empty;
            }
        }
Exemplo n.º 18
0
        public static List <EntityDateRangeStateTypeDataModel> GetEntityDetails(EntityDateRangeStateTypeDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.EntityDateRangeStateTypeSearch ";

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

            List <EntityDateRangeStateTypeDataModel> result;

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

            return(result);
        }
Exemplo n.º 19
0
        public void SetData(EntityDateRangeStateTypeDataModel data)
        {
            SystemKeyId = data.EntityDateRangeStateTypeId;

            base.SetData(data);
        }
Exemplo n.º 20
0
        public static EntityDateRangeStateTypeDataModel GetDetails(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Exemplo n.º 21
0
        public static DataTable Search(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Exemplo n.º 22
0
        public static void Update(EntityDateRangeStateTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

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