Int64 IACTDSHistoryDataAccess.Add(ACTDSHistoryEntity aCTDSHistoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(aCTDSHistoryEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(aCTDSHistoryEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
Int64 IACTDSHistoryDataAccess.Delete(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(aCTDSHistoryEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(aCTDSHistoryEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void PrepareEditView() { ACTDSHistoryEntity aCTDSHistoryEntity = CurrentACTDSHistoryEntity; if (!aCTDSHistoryEntity.IsNew) { } }
private Int64 UpdateTran(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACTDSHistory_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@TDSHistoryID", DbType.Int64, aCTDSHistoryEntity.TDSHistoryID); db.AddInParameter(cmd, "@TDSCategoryID", DbType.Int64, aCTDSHistoryEntity.TDSCategoryID); db.AddInParameter(cmd, "@StartValue", DbType.Decimal, aCTDSHistoryEntity.StartValue); db.AddInParameter(cmd, "@EndValue", DbType.Decimal, aCTDSHistoryEntity.EndValue); db.AddInParameter(cmd, "@Tax", DbType.Decimal, aCTDSHistoryEntity.Tax); db.AddInParameter(cmd, "@Remarks", DbType.String, aCTDSHistoryEntity.Remarks); db.AddInParameter(cmd, "@UpdatedDate", DbType.DateTime, aCTDSHistoryEntity.UpdatedDate); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private Int64 DeleteTran(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACTDSHistory_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
protected void lvACTDSHistory_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 TDSHistoryID; Int64.TryParse(e.CommandArgument.ToString(), out TDSHistoryID); if (TDSHistoryID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _TDSHistoryID = TDSHistoryID; PrepareEditView(); } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(ACTDSHistoryEntity.FLD_NAME_TDSHistoryID, TDSHistoryID.ToString(), SQLMatchType.Equal); ACTDSHistoryEntity aCTDSHistoryEntity = new ACTDSHistoryEntity(); result = FCCACTDSHistory.GetFacadeCreate().Delete(aCTDSHistoryEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _TDSHistoryID = 0; _ACTDSHistoryEntity = new ACTDSHistoryEntity(); PrepareInitialView(); BindACTDSHistoryList(); MiscUtil.ShowMessage(lblMessage, "A CTDSHistory has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete A CTDSHistory.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACTDSHistory_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@TDSHistoryID", DbType.Int64, aCTDSHistoryEntity.TDSHistoryID); Database.AddInParameter(cmd, "@TDSCategoryID", DbType.Int64, aCTDSHistoryEntity.TDSCategoryID); Database.AddInParameter(cmd, "@StartValue", DbType.Decimal, aCTDSHistoryEntity.StartValue); Database.AddInParameter(cmd, "@EndValue", DbType.Decimal, aCTDSHistoryEntity.EndValue); Database.AddInParameter(cmd, "@Tax", DbType.Decimal, aCTDSHistoryEntity.Tax); Database.AddInParameter(cmd, "@Remarks", DbType.String, aCTDSHistoryEntity.Remarks); Database.AddInParameter(cmd, "@UpdatedDate", DbType.DateTime, aCTDSHistoryEntity.UpdatedDate); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("ACTDSHistoryEntity already exists. Please specify another ACTDSHistoryEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("ACTDSHistoryEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("ACTDSHistoryEntity already exists. Please specify another ACTDSHistoryEntity."); } } } } return(returnCode); }
private Int64 Delete(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACTDSHistory_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("ACTDSHistoryEntity already exists. Please specify another ACTDSHistoryEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("ACTDSHistoryEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("ACTDSHistoryEntity already exists. Please specify another ACTDSHistoryEntity."); } } } } return(returnCode); }
Int64 IACTDSHistoryFacade.Delete(ACTDSHistoryEntity aCTDSHistoryEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateACTDSHistoryDataAccess().Delete(aCTDSHistoryEntity, filterExpression, option, reqTran)); }
Int64 IACTDSHistoryFacade.Add(ACTDSHistoryEntity aCTDSHistoryEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateACTDSHistoryDataAccess().Add(aCTDSHistoryEntity, option, reqTran)); }