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); } }
public OrdersDetailsViewModel(IConNodeManager manager, ConnectionNodeDTO order) { _manager = manager; Order = order ?? new ConnectionNodeDTO(); Customers = _manager.GetListOfCustomers(); Items = _manager.GetListOfItems(); Statuses = _manager.GetListOfStatuses(); }
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); }
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); } }
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); } }
public ConnectionNodeDTO UpdateNode(ConnectionNodeDTO node) { return(_connectionNodeDAL.UpdateNode(node)); }
public ConnectionNodeDTO AddNode(ConnectionNodeDTO node) { return(_connectionNodeDAL.CreateteNode(node)); }