コード例 #1
0
        public bool CreateP(RequestLine requestline, string ProductName)
        {
            var productctrl = new ProductController(connection);
            var product     = productctrl.GetByName(ProductName);

            requestline.ProductId = product.Id;
            return(Create(requestline));
        }
コード例 #2
0
        public bool Create(RequestLine requestline, string RequestDescription)
        {
            var RequestCtrl = new RequestController(connection);
            var request     = RequestCtrl.GetByDescription(RequestDescription);

            requestline.RequestId = request.Id;
            return(Create(requestline));
        }
コード例 #3
0
        private RequestLine FillRequestLineFromSqlRow(SqlDataReader reader)
        {
            var requestline = new RequestLine()
            {
                Id        = Convert.ToInt32(reader["Id"]),
                RequestId = Convert.ToInt32(reader["RequestId"]),
                ProductId = Convert.ToInt32(reader["ProductId"]),
                Quantity  = Convert.ToInt32(reader["Quantity"])
            };

            return(requestline);
        }
コード例 #4
0
        public bool Change(RequestLine requestLine)
        {
            var sql = "Update RequestLines set" +
                      " (RequestId, ProductId, Quantity) " +
                      "Values (@requestid, @productid, @quantity);";
            var cmd = new SqlCommand(sql, connection.SqlConn);

            FillCmdParFromSqlRowsForRequestLines(cmd, requestLine);

            var rowsaffected = cmd.ExecuteNonQuery();

            return(rowsaffected == 1);
        }
コード例 #5
0
        private void GetProductForRequestLine(RequestLine requestLine)
        {
            var productctrl = new ProductController(connection);

            requestLine.product = productctrl.GetByPk(requestLine.ProductId);
        }
コード例 #6
0
        private void GetRequestForRequestLine(RequestLine requestLine)
        {
            var requestctrl = new RequestController(connection);

            requestLine.request = requestctrl.GetByPk(requestLine.RequestId);
        }
コード例 #7
0
 private void FillCmdParFromSqlRowsForRequestLines(SqlCommand cmd, RequestLine requestLine)
 {
     cmd.Parameters.AddWithValue("@requestid", requestLine.RequestId);
     cmd.Parameters.AddWithValue("@productid", requestLine.ProductId);
     cmd.Parameters.AddWithValue("@quantity", requestLine.Quantity);
 }