Exemplo n.º 1
0
        public SigmaResultType AddConsumable(TypeConsumable objConsumable)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@Description", objConsumable.Description));
            paramList.Add(new SqlParameter("@PartNumber", objConsumable.PartNumber));
            paramList.Add(new SqlParameter("@Vendor", objConsumable.Vendor));
            paramList.Add(new SqlParameter("@UomCode", objConsumable.UomCode));
            paramList.Add(new SqlParameter("@CreatedBy", objConsumable.CreatedBy));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddConsumable", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;
                scope.Complete();

            }

            return result;
        }
Exemplo n.º 2
0
        public SigmaResultType UpdateConsumable(TypeConsumable objConsumable)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@Description", objConsumable.Description),
                    new SqlParameter("@PartNumber", objConsumable.PartNumber),
                    new SqlParameter("@Vendor", objConsumable.Vendor),
                    new SqlParameter("@UomCode", objConsumable.UomCode),
                    new SqlParameter("@CreatedBy", objConsumable.CreatedBy),
                    new SqlParameter("@UpdatedBy", objConsumable.UpdatedBy),
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateConsumable", parameters);
                result.IsSuccessful = true;
                scope.Complete();

            }

            return result;
        }
        public SigmaResultType UpdateConsumable(TypeConsumable objConsumable)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                result.IsSuccessful = true;
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
Exemplo n.º 4
0
        public SigmaResultType RemoveConsumable(TypeConsumable objConsumable)
        {
            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@ConsumableId", objConsumable.ConsumableId)
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_RemoveConsumable", parameters);
                result.IsSuccessful = true;
                scope.Complete();
            }

            return result;
        }
        public SigmaResultType RemoveConsumable(TypeConsumable objConsumable)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                ConsumableMgr consumableMgr = new ConsumableMgr();
                result = consumableMgr.RemoveConsumable(objConsumable);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }