Пример #1
0
        public ConnectionNodeDTO GetNodeById(int custId, int itemId)
        {
            using (SqlConnection conn = new SqlConnection(this.connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "select * from ConnectionNode where CustomerDataId = @cust AND ItemId = @item";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@cust", custId);
                    comm.Parameters.AddWithValue("@item", itemId);
                    conn.Open();
                    SqlDataReader reader = comm.ExecuteReader();

                    ConnectionNodeDTO node = new ConnectionNodeDTO
                    {
                        CustomerDataId = (int)reader["CustomerDataId"],
                        ItemId         = (int)reader["ItemId"],
                        QuantityOfItem = (int)reader["QuantityOfItem"],
                        SendingTime    = (SqlDateTime)reader["SendingTime"],
                        TimeOfReceipt  = (SqlDateTime)reader["TimeOfReceipt"],
                        StatusId       = (int)reader["StatusId"]
                    };

                    return(node);
                }
        }
Пример #2
0
 public OrdersDetailsViewModel(IConNodeManager manager, ConnectionNodeDTO order)
 {
     _manager  = manager;
     Order     = order ?? new ConnectionNodeDTO();
     Customers = _manager.GetListOfCustomers();
     Items     = _manager.GetListOfItems();
     Statuses  = _manager.GetListOfStatuses();
 }
Пример #3
0
        public void AddNodeTest()
        {
            ConnectionNodeDTO inConNode = new ConnectionNodeDTO
            {
                CustomerDataId = 1,
                ItemId         = 1,
                QuantityOfItem = 5,
                TimeOfReceipt  = SqlDateTime.MinValue,
                SendingTime    = SqlDateTime.Null,
                StatusId       = 1
            };

            var res = manager.AddNode(inConNode);

            Assert.IsNotNull(res);
        }
Пример #4
0
        public ConnectionNodeDTO CreateteNode(ConnectionNodeDTO node)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "insert into ConnectionNode (CustomerDataId, ItemId, QuantityOfItem, TimeOfReceipt, StatusId) values (@customer, @item, @quantity, @receiptTime, @status)";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@customer", node.CustomerDataId);
                    comm.Parameters.AddWithValue("@item", node.ItemId);
                    comm.Parameters.AddWithValue("@quantity", node.QuantityOfItem);
                    comm.Parameters.AddWithValue("@receiptTime", node.TimeOfReceipt); // замість цього можна дати GETDATE()
                    comm.Parameters.AddWithValue("@status", node.StatusId);
                    conn.Open();

                    return(node);
                }
        }
Пример #5
0
        public ConnectionNodeDTO UpdateNode(ConnectionNodeDTO node)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = "update ConnectionNode set CustomerDataId = @customer, ItemId = @item, QuantityOfItem = @quantity, TimeOfReceipt = @receiptTime, SendingTime = @sendTime, StatusId = @status";
                    comm.Parameters.Clear();
                    comm.Parameters.AddWithValue("@customer", node.CustomerDataId);
                    comm.Parameters.AddWithValue("@item", node.ItemId);
                    comm.Parameters.AddWithValue("@quantity", node.QuantityOfItem);
                    comm.Parameters.AddWithValue("@receiptTime", node.TimeOfReceipt);
                    comm.Parameters.AddWithValue("@sendTime", node.SendingTime);
                    comm.Parameters.AddWithValue("@status", node.StatusId);
                    conn.Open();

                    return(node);
                }
        }
Пример #6
0
 public ConnectionNodeDTO UpdateNode(ConnectionNodeDTO node)
 {
     return(_connectionNodeDAL.UpdateNode(node));
 }
Пример #7
0
 public ConnectionNodeDTO AddNode(ConnectionNodeDTO node)
 {
     return(_connectionNodeDAL.CreateteNode(node));
 }