Пример #1
0
        protected override void ShowData(int batchFileSetId)
        {
            base.ShowData(batchFileSetId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var data = new BatchFileSetDataModel();

            data.BatchFileSetId = batchFileSetId;

            var items = Framework.Components.Import.BatchFileSetDataManager.GetEntityDetails(data, SessionVariables.RequestProfile);

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

                lblBatchFileSetId.Text = item.BatchFileSetId.ToString();
                lblName.Text           = item.Name;
                lblDescription.Text    = item.Description;

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

                oHistoryList.Setup(PrimaryEntity, batchFileSetId, "BatchFileSet");
            }
        }
Пример #2
0
        private static string Save(BatchFileSetDataModel data, RequestProfile requestProfile, string action)
        {
            var sql = "EXEC ";

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

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

            default:
                break;
            }

            sql = sql + ", " + ToSQLParameter(data, BatchFileSetDataModel.DataColumns.BatchFileSetId) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) +
                  ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description);
            //", " + ToSQLParameter(data, BaseDataModel.BaseDataColumns.CreatedDate) +
            //", " + ToSQLParameter(data, BatchFileSetDataModel.DataColumns.CreatedByPersonId);
            return(sql);
        }
Пример #3
0
        public static List <BatchFileSetDataModel> GetEntityDetails(BatchFileSetDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.BatchFileSetSearch ";

            var parameters =
                new
            {
                AuditId             = requestProfile.AuditId
                , ApplicationMode   = requestProfile.ApplicationModeId
                , ApplicationId     = dataQuery.ApplicationId
                , BatchFileSetId    = dataQuery.BatchFileSetId
                , Name              = dataQuery.Name
                , CreatedByPersonId = dataQuery.CreatedByPersonId
            };

            List <BatchFileSetDataModel> result;

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



            return(result);
        }
Пример #4
0
        public override int?Save(string action)
        {
            var data = new BatchFileSetDataModel();

            data.BatchFileSetId = BatchFileSetId;
            data.Name           = Name;
            data.Description    = Description;

            if (action == "Insert")
            {
                var dtBatchFileSet = Framework.Components.Import.BatchFileSetDataManager.DoesExist(data, SessionVariables.RequestProfile);

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

            // not correct ... when doing insert, we didn't get/change the value of BatchFileSetID ?
            return(BatchFileSetId);
        }
Пример #5
0
        public static string ToSQLParameter(BatchFileSetDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

            return(returnValue);
        }
Пример #6
0
        public static DataTable GetDetails(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            var table = list.ToDataTable();

            return(table);
        }
Пример #7
0
        public static DataTable DoesExist(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new BatchFileSetDataModel();

            doesExistRequest.Name = data.Name;

            return(Search(doesExistRequest, requestProfile));
        }
Пример #8
0
        public static DataTable Search(BatchFileSetDataModel data, RequestProfile requestProfile, int applicationMode = 0)
        {
            var list = GetEntityDetails(data, requestProfile);

            var table = list.ToDataTable();

            return(table);
        }
Пример #9
0
        private System.Data.DataTable GetData()
        {
            // TODO: on all export pages
            var data = new BatchFileSetDataModel();

            var dt = Framework.Components.Import.BatchFileSetDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Пример #10
0
        private DataTable GetData(string name)
        {
            var data = new BatchFileSetDataModel();

            data.Name = name;
            var dt = Framework.Components.Import.BatchFileSetDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
Пример #11
0
        public static bool DoesExist(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new BatchFileSetDataModel();

            doesExistRequest.Name = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile);

            return(list.Count > 0);
        }
Пример #12
0
        private static DataSet GetChildren(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var sql = "EXEC dbo.BatchFileSetChildrenGet " +
                      " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                      ", " + ToSQLParameter(data, BatchFileSetDataModel.DataColumns.BatchFileSetId);

            var oDT = new DataAccess.DBDataSet("Get Children", sql, DataStoreKey);

            return(oDT.DBDataset);
        }
Пример #13
0
        protected override void Clear()
        {
            base.Clear();

            var data = new BatchFileSetDataModel();

            BatchFileSetId = data.BatchFileSetId;
            Description    = data.Description;
            Name           = data.Name;
        }
Пример #14
0
        public static void Delete(BatchFileSetDataModel dataQuery, RequestProfile requestProfile)
        {
            const string sql = @"dbo.BatchFileSetDelete ";

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

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Пример #15
0
        public static bool IsDeletable(BatchFileSetDataModel 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);
        }
Пример #16
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var      notDeletableIds = new List <int>();
         string[] deleteIndexList = DeleteIds.Split(',');
         foreach (string index in deleteIndexList)
         {
             var data = new BatchFileSetDataModel();
             data.BatchFileSetId = int.Parse(index);
             if (!Framework.Components.Import.BatchFileSetDataManager.IsDeletable(data, SessionVariables.RequestProfile))
             {
                 notDeletableIds.Add(Convert.ToInt32(data.BatchFileSetId));
             }
         }
         if (notDeletableIds.Count == 0)
         {
             foreach (string index in deleteIndexList)
             {
                 var data = new BatchFileSetDataModel();
                 data.BatchFileSetId = int.Parse(index);
                 Framework.Components.Import.BatchFileSetDataManager.Delete(data, SessionVariables.RequestProfile);
             }
             DeleteAndRedirect();
         }
         else
         {
             var msg = String.Empty;
             foreach (var id in notDeletableIds)
             {
                 if (!string.IsNullOrEmpty(msg))
                 {
                     msg += ", <br/>";
                 }
                 msg += "BatchFileSetId: " + id + " has detail records";
             }
             Response.Write(msg);
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Пример #17
0
        public void LoadData(int batchFileSetId, bool showId)
        {
            // clear UI

            Clear();

            var dataQuery = new BatchFileSetDataModel();

            dataQuery.BatchFileSetId = batchFileSetId;

            var items = Framework.Components.Import.BatchFileSetDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

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

            var item = items[0];

            BatchFileSetId = item.BatchFileSetId;
            Name           = item.Name;
            Description    = item.Description;

            if (!showId)
            {
                txtBatchFileSetId.Text = item.BatchFileSetId.ToString();

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

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
Пример #18
0
        public static BatchFileSetDataModel GetDetails(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile);

            return(list.FirstOrDefault());
        }
Пример #19
0
        public static void Update(BatchFileSetDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, requestProfile, "Update");

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