public void Add(PartInvoice invoice)
        {
            string _ConnectionString = ConfigurationManager.ConnectionStrings["appDatabase"].ConnectionString;

            using (SqlConnection _Connection = new SqlConnection(_ConnectionString))
            {
                SqlCommand _Command = new SqlCommand
                {
                    Connection  = _Connection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "PMS_AddPartInvoice"
                };

                SqlParameter _StockCodeParameter = new SqlParameter("@StockCode", SqlDbType.VarChar, 50)
                {
                    Value = invoice.StockCode
                };
                _Command.Parameters.Add(_StockCodeParameter);
                SqlParameter QuantityParameter = new SqlParameter("@Quantity", SqlDbType.Int)
                {
                    Value = invoice.Quantity
                };
                _Command.Parameters.Add(QuantityParameter);
                SqlParameter CustomerIDParameter = new SqlParameter("@CustomerID", SqlDbType.Int)
                {
                    Value = invoice.CustomerID
                };
                _Command.Parameters.Add(CustomerIDParameter);

                _Connection.Open();
                _Command.ExecuteNonQuery();
            }
        }
        public void Add(PartInvoice invoice)
        {
            using (SqlConnection _Connection = RepositoryDBUtils.GetSqlConnection())
            {
                SqlCommand _Command = new SqlCommand
                {
                    Connection  = _Connection,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "PMS_AddPartInvoice"
                };

                SqlParameter _StockCodeParameter = new SqlParameter("@StockCode", SqlDbType.VarChar, 50)
                {
                    Value = invoice.StockCode
                };
                _Command.Parameters.Add(_StockCodeParameter);
                SqlParameter QuantityParameter = new SqlParameter("@Quantity", SqlDbType.Int)
                {
                    Value = invoice.Quantity
                };
                _Command.Parameters.Add(QuantityParameter);
                SqlParameter CustomerIDParameter = new SqlParameter("@CustomerID", SqlDbType.Int)
                {
                    Value = invoice.CustomerID
                };
                _Command.Parameters.Add(CustomerIDParameter);

                _Connection.Open();
                _Command.ExecuteNonQuery();
            }
        }
        public CreatePartInvoiceResult CreatePartInvoice(string stockCode, int quantity, string customerName)
        {
            //validate inputs
            if (IsStockCodeValid(stockCode) &&
                IsQuantityValid(quantity) &&
                IsCustomerValid(customerName))
            {
                if (IsAvailable(stockCode))
                {
                    PartInvoice _PartInvoice = new PartInvoice
                    {
                        StockCode  = stockCode,
                        Quantity   = quantity,
                        CustomerID = _Customer.ID
                    };
                    _PartInvoiceRepository.Add(_PartInvoice);

                    return(new CreatePartInvoiceResult(true));
                }
                return(new CreatePartInvoiceResult(false));
            }
            return(new CreatePartInvoiceResult(false));
        }
 public void Add(PartInvoice invoice)
 {
     new AddPartInvoiceQuery(invoice).ExecuteQuery();
 }