Exemple #1
0
        Int64 IPRMWorkOrderItemFloorDetailDataAccess.Add(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(pRMWorkOrderItemFloorDetailEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(pRMWorkOrderItemFloorDetailEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        private Int64 UpdateTran(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderItemFloorDetail_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, "@WorkOrderItemFloorDetailID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderItemFloorDetailID);
                db.AddInParameter(cmd, "@WorkOrderItemMapID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderItemMapID);
                db.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderID);
                db.AddInParameter(cmd, "@RequisitionID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.RequisitionID);
                db.AddInParameter(cmd, "@RequisitionItemID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.RequisitionItemID);
                db.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.ProjectFloorID);
                db.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.ProjectFloorUnitID);
                db.AddInParameter(cmd, "@Qty", DbType.Decimal, pRMWorkOrderItemFloorDetailEntity.Qty);
                db.AddInParameter(cmd, "@Rate", DbType.Decimal, pRMWorkOrderItemFloorDetailEntity.Rate);
                db.AddInParameter(cmd, "@Remarks", DbType.String, pRMWorkOrderItemFloorDetailEntity.Remarks);
                db.AddInParameter(cmd, "@EntryDate", DbType.DateTime, pRMWorkOrderItemFloorDetailEntity.EntryDate);

                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);
        }
Exemple #3
0
        private Int64 DeleteTran(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderItemFloorDetail_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);
        }
Exemple #4
0
        private Int64 Update(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderItemFloorDetail_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@WorkOrderItemFloorDetailID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderItemFloorDetailID);
                Database.AddInParameter(cmd, "@WorkOrderItemMapID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderItemMapID);
                Database.AddInParameter(cmd, "@WorkOrderID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.WorkOrderID);
                Database.AddInParameter(cmd, "@RequisitionID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.RequisitionID);
                Database.AddInParameter(cmd, "@RequisitionItemID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.RequisitionItemID);
                Database.AddInParameter(cmd, "@ProjectFloorID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.ProjectFloorID);
                Database.AddInParameter(cmd, "@ProjectFloorUnitID", DbType.Int64, pRMWorkOrderItemFloorDetailEntity.ProjectFloorUnitID);
                Database.AddInParameter(cmd, "@Qty", DbType.Decimal, pRMWorkOrderItemFloorDetailEntity.Qty);
                Database.AddInParameter(cmd, "@Rate", DbType.Decimal, pRMWorkOrderItemFloorDetailEntity.Rate);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, pRMWorkOrderItemFloorDetailEntity.Remarks);
                Database.AddInParameter(cmd, "@EntryDate", DbType.DateTime, pRMWorkOrderItemFloorDetailEntity.EntryDate);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("PRMWorkOrderItemFloorDetailEntity already exists. Please specify another PRMWorkOrderItemFloorDetailEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMWorkOrderItemFloorDetailEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMWorkOrderItemFloorDetailEntity already exists. Please specify another PRMWorkOrderItemFloorDetailEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
Exemple #5
0
        private Int64 Delete(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMWorkOrderItemFloorDetail_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("PRMWorkOrderItemFloorDetailEntity already exists. Please specify another PRMWorkOrderItemFloorDetailEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMWorkOrderItemFloorDetailEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMWorkOrderItemFloorDetailEntity already exists. Please specify another PRMWorkOrderItemFloorDetailEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
 Int64 IPRMWorkOrderItemFloorDetailFacade.Delete(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMWorkOrderItemFloorDetailDataAccess().Delete(pRMWorkOrderItemFloorDetailEntity, filterExpression, option, reqTran));
 }
 Int64 IPRMWorkOrderItemFloorDetailFacade.Add(PRMWorkOrderItemFloorDetailEntity pRMWorkOrderItemFloorDetailEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMWorkOrderItemFloorDetailDataAccess().Add(pRMWorkOrderItemFloorDetailEntity, option, reqTran));
 }