Beispiel #1
0
        private static string Save(TypeOfIssueDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

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

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, TypeOfIssueDataModel.DataColumns.TypeOfIssueId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, TypeOfIssueDataModel.DataColumns.Category) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder);
            return(sql);
        }
Beispiel #2
0
        public static string ToSQLParameter(TypeOfIssueDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

            return(returnValue);
        }
Beispiel #3
0
        protected override void ShowData(int typeOfIssueId)
        {
            base.ShowData(typeOfIssueId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new TypeOfIssueDataModel();

            data.TypeOfIssueId = typeOfIssueId;


            var items = Framework.Components.Audit.TypeOfIssueDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

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

                lblTypeOfIssueId.Text = item.TypeOfIssueId.ToString();
                lblCategory.Text      = item.Category;
                lblName.Text          = item.Name;
                lblDescription.Text   = item.Description;
                lblSortOrder.Text     = item.SortOrder.ToString();

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

                oHistoryList.Setup(PrimaryEntity, typeOfIssueId, "TypeOfIssue");
            }
        }
Beispiel #4
0
        public override int?Save(string action)
        {
            var data = new TypeOfIssueDataModel();

            data.TypeOfIssueId = TypeOfIssueId;
            data.Category      = Category;
            data.Name          = Name;
            data.Description   = Description;
            data.SortOrder     = SortOrder;

            if (action == "Insert")
            {
                var dtTypeOfIssue = Framework.Components.Audit.TypeOfIssueDataManager.DoesExist(data, SessionVariables.RequestProfile);

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

            // not correct ... when doing insert, we didn't get/change the value of TypeOfIssueID ?
            return(TypeOfIssueId);
        }
Beispiel #5
0
        public static DataTable DoesExist(TypeOfIssueDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new TypeOfIssueDataModel();

            doesExistRequest.Name = data.Name;

            return(Search(doesExistRequest, requestProfile));
        }
Beispiel #6
0
        public static DataTable Search(TypeOfIssueDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            var table = list.ToDataTable();

            return(table);
        }
Beispiel #7
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new TypeOfIssueDataModel();

            var dt = Framework.Components.Audit.TypeOfIssueDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Beispiel #8
0
        private DataTable GetData(string name)
        {
            var data = new TypeOfIssueDataModel();

            data.Name = name;

            var dt = Framework.Components.Audit.TypeOfIssueDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Beispiel #9
0
        protected override void Clear()
        {
            base.Clear();

            var data = new TypeOfIssueDataModel();

            TypeOfIssueId = data.TypeOfIssueId;
            Category      = data.Category;
            Description   = data.Description;
            Name          = data.Name;
            SortOrder     = data.SortOrder;
        }
Beispiel #10
0
        public static void Delete(TypeOfIssueDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.TypeOfIssueDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Beispiel #11
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string[] deleteIndexList = DeleteIds.Split(',');
                foreach (string index in deleteIndexList)
                {
                    var data = new TypeOfIssueDataModel();
                    data.TypeOfIssueId = int.Parse(index);
                    Framework.Components.Audit.TypeOfIssueDataManager.Delete(data, SessionVariables.RequestProfile);
                }

                DeleteAndRedirect();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Beispiel #12
0
        public void LoadData(int typeOfIssueId, bool showId)
        {
            // clear UI

            Clear();

            var dataQuery = new TypeOfIssueDataModel();

            dataQuery.TypeOfIssueId = typeOfIssueId;

            var items = Framework.Components.Audit.TypeOfIssueDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

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

            var item = items[0];

            TypeOfIssueId = item.TypeOfIssueId;
            Category      = item.Category;
            Name          = item.Name;
            Description   = item.Description;
            SortOrder     = item.SortOrder;

            if (!showId)
            {
                txtTypeOfIssueId.Text = item.TypeOfIssueId.ToString();

                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.TypeOfIssue, typeOfIssueId, "TypeOfIssue");
            }
            else
            {
                txtTypeOfIssueId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
Beispiel #13
0
        public static List <TypeOfIssueDataModel> GetEntityDetails(TypeOfIssueDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.TypeOfIssueSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , TypeOfIssueId   = dataQuery.TypeOfIssueId
                , Name            = dataQuery.Name
                , Category        = dataQuery.Category
                , ReturnAuditInfo = returnAuditInfo
            };

            List <TypeOfIssueDataModel> result;

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

            return(result);
        }
Beispiel #14
0
        public static TypeOfIssueDataModel GetDetails(TypeOfIssueDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 1);

            return(list.FirstOrDefault());
        }
Beispiel #15
0
        public static void Update(TypeOfIssueDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, requestProfile, "Update");

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