Exemplo n.º 1
0
        public userAppObj getuser(String nome, String senha)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    SELECT	A.USER_ID
	                                       ,A.USER_NAME
                                           ,A.USER_LOGIN
	                                       ,A.USER_PASSWORD
                                    FROM	systemUser   A WITH(NOLOCK)
                                    WHERE	A.USER_LOGIN      = @systemNm
                                    AND     A.USER_PASSWORD   = @systemPws
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("systemNm", nome);
            dbQuery.CreateParameter("systemPws", senha);

            IDataReader iReader = dbQuery.ExecuteDataReader(CommandBehavior.CloseConnection);

            userAppObj _data = new userAppObj();
            while (iReader.Read())
            {
                _data.id   = Convert.ToInt32(iReader["USER_ID"]);
                _data.nome = Convert.ToString(iReader["USER_NAME"]);
            }
            iReader.Close();

            return(_data);
        }
        public productObj update(productObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    UPDATE	systemProduct
                                    SET     PRODUCT_NAME  = @productName
                                           ,PRODUCT_PRICE = @productPrice
                                           ,PRODUCT_AMOUNT= @productAmont
                                    WHERE   PRODUCT_ID    = @productId
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("productId", _data.productId);
            dbQuery.CreateParameter("productName", _data.productNome);
            dbQuery.CreateParameter("productPrice", _data.productPrice);
            dbQuery.CreateParameter("productAmont", _data.productAmount);

            dbQuery.ExecuteCommand();

            return(_data);
        }
Exemplo n.º 3
0
        public orderObj update(orderObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    UPDATE	systemOrder
                                    SET     USER_ID    = @userId
                                           ,PRODUCT_ID = @productId
                                    WHERE   ORDER_ID   = @orderId
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("orderId", _data.orderId);
            dbQuery.CreateParameter("userId", _data.userId);
            dbQuery.CreateParameter("productId", _data.productId);

            dbQuery.ExecuteCommand();

            return(_data);
        }
Exemplo n.º 4
0
        public orderObj insert(orderObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    INSERT 
                                        INTO systemOrder
                                            (
                                                USER_ID
                                               ,PRODUCT_ID
                                               ,ORDER_DATE
                                            )
                                        VALUES
                                            (
                                                @userId
                                               ,@productId
                                               ,GETDATE()
                                            )
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("userId", _data.userId);
            dbQuery.CreateParameter("productId", _data.productId);

            dbQuery.ExecuteCommand();

            return(_data);
        }
Exemplo n.º 5
0
        public List <orderListObj> selectAll(orderObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    SELECT	B.PRODUCT_NAME
                                           ,B.PRODUCT_DATE
	                                       ,A.ORDER_DATE
                                    FROM	systemOrder		A WITH(NOLOCK)
                                    JOIN	systemProduct	B WITH(NOLOCK) ON B.PRODUCT_ID = A.PRODUCT_ID
                                    WHERE	A.USER_ID = @userId
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("userId", _data.userId);

            IDataReader iReader = dbQuery.ExecuteDataReader(CommandBehavior.CloseConnection);

            List <orderListObj> _dataList = new List <orderListObj>();
            while (iReader.Read())
            {
                _dataList.Add
                (
                    new orderListObj()
                {
                    productName   = Convert.ToString(iReader["PRODUCT_NAME"])
                    , productDate = Convert.ToDateTime(iReader["PRODUCT_DATE"])
                    , orderDate   = Convert.ToDateTime(iReader["ORDER_DATE"])
                }
                );
            }
            iReader.Close();

            return(_dataList);
        }
        public List <productObj> selectAll()
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    SELECT	A.PRODUCT_ID
	                                       ,A.PRODUCT_NAME
                                           ,A.PRODUCT_PRICE
	                                       ,A.PRODUCT_DATE
                                           ,A.PRODUCT_AMOUNT
                                    FROM	systemProduct   A WITH(NOLOCK)
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            IDataReader iReader = dbQuery.ExecuteDataReader(CommandBehavior.CloseConnection);

            List <productObj> _data = new List <productObj>();
            while (iReader.Read())
            {
                _data.Add
                (
                    new productObj()
                {
                    productId      = Convert.ToInt32(iReader["PRODUCT_ID"])
                    , productNome  = Convert.ToString(iReader["PRODUCT_NAME"])
                    , productPrice = Convert.ToDecimal(iReader["PRODUCT_PRICE"])
                }
                );
            }
            iReader.Close();

            return(_data);
        }
        public productObj select(productObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    SELECT	A.PRODUCT_ID
	                                       ,A.PRODUCT_NAME
                                           ,A.PRODUCT_PRICE
	                                       ,A.PRODUCT_DATE
                                           ,A.PRODUCT_AMOUNT
                                    FROM	systemProduct   A WITH(NOLOCK)
                                    WHERE   A.PRODUCT_ID = @productId
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("productId", _data.productId);

            IDataReader iReader = dbQuery.ExecuteDataReader(CommandBehavior.CloseConnection);

            while (iReader.Read())
            {
                _data.productId     = Convert.ToInt32(iReader["PRODUCT_ID"]);
                _data.productNome   = Convert.ToString(iReader["PRODUCT_NAME"]);
                _data.productPrice  = Convert.ToDecimal(iReader["PRODUCT_PRICE"]);
                _data.productAmount = Convert.ToInt32(iReader["PRODUCT_AMOUNT"]);
                _data.productDate   = Convert.ToDateTime(iReader["PRODUCT_DATE"]);
            }
            iReader.Close();

            return(_data);
        }
        public productObj insert(productObj _data)
        {
            #region QuerySQL
            String _stQuery = String.Format
                                  (@"
                                    INSERT 
                                        INTO systemProduct
                                            (
                                                PRODUCT_NAME
                                               ,PRODUCT_PRICE
	                                           ,PRODUCT_AMOUNT
                                               ,PRODUCT_DATE
                                            )
                                        VALUES
                                            (
                                                @productName
                                               ,@productPrice
                                               ,@productAmont
                                               ,GETDATE()
                                            )
                                  ");
            #endregion QuerySQL

            gmjDatabase dbQuery = new gmjDatabase();
            dbQuery.CommandText    = _stQuery;
            dbQuery.CommandType    = CommandType.Text;
            dbQuery.CommandTimeout = 240000;

            dbQuery.CreateParameter("productName", _data.productNome);
            dbQuery.CreateParameter("productPrice", _data.productPrice);
            dbQuery.CreateParameter("productAmont", _data.productAmount);

            dbQuery.ExecuteCommand();

            return(_data);
        }