public static List <BatchFileDataModel> GetEntityDetails(BatchFileDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.BatchFileSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ReturnAuditInfo = returnAuditInfo , BatchFileId = dataQuery.BatchFileId , Name = dataQuery.Name , BatchFileStatusId = dataQuery.BatchFileStatusId , BatchFileSetId = dataQuery.BatchFileSetId }; List <BatchFileDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <BatchFileDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
private DataTable GetData() { var data = new BatchFileDataModel(); var dt = Framework.Components.Import.BatchFileDataManager.Search(data, SessionVariables.RequestProfile); return(dt); }
public override int?Save(string action) { var data = new BatchFileDataModel(); data.BatchFileId = BatchFileId; data.BatchFileSetId = BatchFileSetId; data.BatchFileStatusId = BatchFileStatusId; data.FileTypeId = FileTypeId; data.SystemEntityTypeId = SystemEntityTypeId; data.Name = Name; data.Description = Description; if (action == "Insert") { var dtBatchFileSet = Framework.Components.Import.BatchFileDataManager.DoesExist(data, SessionVariables.RequestProfile); if (dtBatchFileSet.Rows.Count == 0) { Framework.Components.Import.BatchFileDataManager.Create(data, SessionVariables.RequestProfile); } else { throw new Exception("Record with given ID already exists."); } } else { Framework.Components.Import.BatchFileDataManager.Update(data, SessionVariables.RequestProfile); } // not correct ... when doing insert, we didn't get/change the value of BatchFileSetID ? return(BatchFileSetId); }
public static DataTable DoesExist(BatchFileDataModel data, RequestProfile requestProfile) { var doesExistRequest = new BatchFileDataModel(); doesExistRequest.Name = data.Name; return(Search(doesExistRequest, requestProfile)); }
private System.Data.DataTable GetData() { // TODO: on all export pages var data = new BatchFileDataModel(); var dt = Framework.Components.Import.BatchFileDataManager.Search(data, SessionVariables.RequestProfile); return(dt); }
public static bool DoesExist(BatchFileDataModel data, RequestProfile requestProfile) { var doesExistRequest = new BatchFileDataModel(); doesExistRequest.Name = data.Name; var list = Search(doesExistRequest, requestProfile); return(list.Rows.Count > 0); }
private static DataSet GetChildren(BatchFileDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.BatchFileChildrenGet " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileId); var oDT = new DataAccess.DBDataSet("Get Children", sql, DataStoreKey); return(oDT.DBDataset); }
public static DataTable GetDetails(BatchFileDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.BatchFileSearch " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ReturnAuditInfo, BaseDataManager.ReturnAuditInfoOnDetails) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileId); var oDT = new DataAccess.DBDataTable("BatchFile.Details", sql, DataStoreKey); return(oDT.DBTable); }
private static string Save(BatchFileDataModel data, RequestProfile requestProfile, string action) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.BatchFileInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.BatchFileUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.Folder) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFile) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileSetId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.Description) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.FileTypeId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.SystemEntityTypeId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileStatusId) + ", " + ToSQLParameter(data, BaseDataModel.BaseDataColumns.CreatedDate) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.CreatedByPersonId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.UpdatedDate) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.UpdatedByPersonId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.Errors); //", " + data.ToSQLParameter(DataColumns.Name) + //", " + data.ToSQLParameter(DataColumns.Folder) + //", " + data.ToSQLParameter(DataColumns.BatchFile) + //", " + data.ToSQLParameter(DataColumns.BatchFileSetId) + //", " + data.ToSQLParameter(DataColumns.Description) + //", " + data.ToSQLParameter(DataColumns.FileTypeId) + //", " + data.ToSQLParameter(DataColumns.SystemEntityTypeId) + //", " + data.ToSQLParameter(DataColumns.BatchFileStatusId) + //", " + data.ToSQLParameter(DataColumns.CreatedDate) + //", " + data.ToSQLParameter(DataColumns.CreatedByPersonId) + //", " + data.ToSQLParameter(DataColumns.UpdatedDate) + //", " + data.ToSQLParameter(DataColumns.UpdatedByPersonId) + //", " + data.ToSQLParameter(DataColumns.Errors); return(sql); }
public void LoadData(int batchFileId, bool showId) { var data = new BatchFileDataModel(); data.BatchFileId = batchFileId; var oBatchFileTable = Framework.Components.Import.BatchFileDataManager.GetDetails(data, SessionVariables.RequestProfile); if (oBatchFileTable.Rows.Count == 1) { var row = oBatchFileTable.Rows[0]; if (!showId) { txtBatchFileId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileId]); // only show Audit History in case of Update page, not for Clone. oHistoryList.Setup((int)Framework.Components.DataAccess.SystemEntity.BatchFile, batchFileId, "BatchFile"); dynAuditHistory.Visible = PerferenceUtility.GetUserPreferenceByKeyAsBoolean(ApplicationCommon.HistoryGridVisibilityKey, "BatchFile"); oUpdateInfo.LoadText(oBatchFileTable.Rows[0]); } else { txtBatchFileId.Text = String.Empty; } txtName.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.Name]); txtDescription.Text = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]); txtBatchFileSetId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileSetId]); txtFileTypeId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.FileTypeId]); txtSystemEntityTypeId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.SystemEntityTypeId]); txtBatchFileStatusId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileStatusId]); drpSystemEntityTypeList.SelectedValue = Convert.ToString(row[BatchFileDataModel.DataColumns.SystemEntityTypeId]); drpFileTypeList.SelectedValue = Convert.ToString(row[BatchFileDataModel.DataColumns.FileTypeId]); drpBatchFileStatusList.SelectedValue = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileStatusId]); drpBatchFileSetList.SelectedValue = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileSetId]); oUpdateInfo.LoadText(oBatchFileTable.Rows[0]); } else { txtName.Text = String.Empty; txtBatchFileId.Text = String.Empty; txtDescription.Text = String.Empty; txtBatchFileSetId.Text = String.Empty; txtFileTypeId.Text = String.Empty; txtSystemEntityTypeId.Text = String.Empty; txtBatchFileStatusId.Text = String.Empty; } }
public static DataTable Search(BatchFileDataModel data, RequestProfile requestProfile) { // formulate SQL var sql = "EXEC dbo.BatchFileSearch " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileStatusId) + ", " + ToSQLParameter(data, BatchFileDataModel.DataColumns.BatchFileSetId); var oDT = new DataAccess.DBDataTable("BatchFile.Search", sql, DataStoreKey); return(oDT.DBTable); }
public static void Delete(BatchFileDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.BatchFileDelete "; var parameters = new { AuditId = requestProfile.AuditId , BatchFileId = data.BatchFileId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static bool IsDeletable(BatchFileDataModel 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); }
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 BatchFileDataModel(); data.BatchFileId = int.Parse(index); if (!Framework.Components.Import.BatchFileDataManager.IsDeletable(data, SessionVariables.RequestProfile)) { notDeletableIds.Add(Convert.ToInt32(data.BatchFileId)); } } if (notDeletableIds.Count == 0) { foreach (string index in deleteIndexList) { var data = new BatchFileDataModel(); data.BatchFileId = int.Parse(index); Framework.Components.Import.BatchFileDataManager.Delete(data, SessionVariables.RequestProfile); } DeleteAndRedirect(); } else { var msg = String.Empty; foreach (var id in notDeletableIds) { if (!string.IsNullOrEmpty(msg)) { msg += ", <br/>"; } msg += "BatchFileId: " + id + " has detail records"; } Response.Write(msg); } } catch (Exception ex) { Response.Write(ex.Message); } }
protected override void ShowData(int batchFileId) { oDetailButtonPanel.SetId = SetId; var data = new BatchFileDataModel(); data.BatchFileId = batchFileId; var dt = Framework.Components.Import.BatchFileDataManager.GetDetails(data, SessionVariables.RequestProfile); if (dt.Rows.Count == 1) { var row = dt.Rows[0]; lblBatchFileId.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileId]); lblName.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.Name]); lblFolder.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.Folder]); lblBatchFile.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFile]); lblBatchFileSet.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileSetId]); lblDescription.Text = Convert.ToString(row[StandardDataModel.StandardDataColumns.Description]); lblFileType.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.FileTypeId]); lblSystemEntityType.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.SystemEntityTypeId]); lblBatchFileStatus.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.BatchFileStatusId]); lblCreatedDate.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.CreatedDate]); lblCreatedByPerson.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.CreatedByPersonId]); lblErrors.Text = Convert.ToString(row[BatchFileDataModel.DataColumns.Errors]); oUpdateInfo.LoadText(dt.Rows[0]); oHistoryList.Setup("AuditHistory", "Audit", "AuditHistoryId", true, true, (int)Framework.Components.DataAccess.SystemEntity.BatchFile, batchFileId, "BatchFile"); dynAuditHistory.Visible = PerferenceUtility.GetUserPreferenceByKeyAsBoolean(ApplicationCommon.HistoryGridVisibilityKey, "BatchFile"); } else { Clear(); } }
public static BatchFileDataModel GetDetails(BatchFileDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 1); return(list.FirstOrDefault()); }
public static string ToSQLParameter(BatchFileDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case BatchFileDataModel.DataColumns.BatchFileId: if (data.BatchFileId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.BatchFileId, data.BatchFileId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.BatchFileId); } break; case BatchFileDataModel.DataColumns.FileTypeId: if (data.FileTypeId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.FileTypeId, data.FileTypeId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.FileTypeId); } break; case BatchFileDataModel.DataColumns.BatchFileSetId: if (data.BatchFileSetId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.BatchFileSetId, data.BatchFileSetId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.BatchFileSetId); } break; case BatchFileDataModel.DataColumns.BatchFileStatusId: if (data.BatchFileStatusId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.BatchFileStatusId, data.BatchFileStatusId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.BatchFileStatusId); } break; case BatchFileDataModel.DataColumns.SystemEntityTypeId: if (data.SystemEntityTypeId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.SystemEntityTypeId, data.SystemEntityTypeId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.SystemEntityTypeId); } break; case BatchFileDataModel.DataColumns.Folder: if (!string.IsNullOrEmpty(data.Folder)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, BatchFileDataModel.DataColumns.Folder, data.Folder); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.Folder); } break; case BatchFileDataModel.DataColumns.BatchFile: if (!string.IsNullOrEmpty(data.BatchFile)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, BatchFileDataModel.DataColumns.BatchFile, data.BatchFile); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.BatchFile); } break; case BatchFileDataModel.DataColumns.Errors: if (!string.IsNullOrEmpty(data.Errors)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, BatchFileDataModel.DataColumns.Errors, data.Errors); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.Errors); } break; case BatchFileDataModel.DataColumns.CreatedByPersonId: if (data.CreatedByPersonId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BatchFileDataModel.DataColumns.CreatedByPersonId, data.CreatedByPersonId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BatchFileDataModel.DataColumns.CreatedByPersonId); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static void Update(BatchFileDataModel data, RequestProfile requestProfile) { var sql = Save(data, requestProfile, "Update"); DataAccess.DBDML.RunSQL("BatchFile.Update", sql, DataStoreKey); }