private async Task RaiseItemReceived(T item) { await Task.Run(() => { ReceivedItem?.Invoke(Key, item); }); }
private void cmdOk_Click(object sender, EventArgs e) { int count = 0; int index = 0; ReceivedItem item; if (cmbOrder.SelectedIndex >= 0) // if whether order is selected { foreach (OrderItem a in orderitems) { if (lstItems.Items[count].Checked == true) //get only check items { item = new ReceivedItem(); item.OrderItem = orderitems[count]; item.Quantity = orderitems[count].Quantity; receiveditems.Add(item); DataAccess.InsertReceivedItem(item); // add received items to database DataAccess.UpdateItemQuantity(orderitems[count].Item, item.Quantity); // update stock index++; } count++; } if (index == 0) //check whether items are selected { // show error message if no items selected MessageBox.Show("Received items cannot be empty!, please select received items", "info", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } orders[cmbOrder.SelectedIndex].IsReceived = true; DataAccess.UpdateOrder(orders[cmbOrder.SelectedIndex]); // set order received status to true in database MessageBox.Show("Infomration Added Successfully", "info", MessageBoxButtons.OK, MessageBoxIcon.Information); //Show message if success if (chkPrint.Checked) // if print grn checked { try { docGRN.DefaultPageSettings.Margins = new Margins(50, 50, 50, 50); docGRN.Print(); // print GRN } catch (InvalidPrinterException) { // show error message if error occurs while printing MessageBox.Show("An error occurred while printing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // close and dispose this form this.Close(); this.Dispose(); } else { MessageBox.Show("Please select a order!", "info", MessageBoxButtons.OK, MessageBoxIcon.Information); // show error message if no order selected } }
public void Test18_Orderreceived() { IDictionary <String, String> filter = new Dictionary <String, String>(); filter.Add("Received", "0"); orders = DataAccess.GetOrders(null, filter); List <OrderItem> OrderItems = DataAccess.GetOrderItems(order); foreach (OrderItem a in OrderItems) { ReceivedItem b = new ReceivedItem(); b.OrderItem = a; b.Quantity = a.Quantity; Assert.AreEqual(1, DataAccess.InsertReceivedItem(b)); } }
// inserts a Received Item using configured Database connection public static int InsertReceivedItem(ReceivedItem item) { int i = 0; try { OdbcCommand scmd = new OdbcCommand("INSERT INTO receiveditem (ItemRef, Quantity,receivedDate) VALUES(?,?,curdate())", DBConnection.getConnection()); scmd.Parameters.Add("@ItemRef", OdbcType.Int).Value = item.OrderItem.Ref; scmd.Parameters.Add("@Quantity", OdbcType.Int).Value = item.Quantity; i = scmd.ExecuteNonQuery(); //item.Ref = GetLastInsert(); } catch (Exception e) { SetErrMsg(e.Message); } return(i); }
private async Task <IEnumerable <ReceivedItem> > Receive() { if (_client.State != WebSocketState.Open) { return(Enumerable.Empty <ReceivedItem>()); } var totalReceived = new List <byte>(); WebSocketReceiveResult receiveResult; var result = new List <ReceivedItem>(); do { try { receiveResult = await _client.ReceiveAsync(_buffer, CancellationToken.None); } catch (AggregateException ex) { throw new IssPlusWebSocketClientException("Invalid receiving", ex); } if (receiveResult.CloseStatusDescription != null) { throw new IssPlusWebSocketClientReceiveException(receiveResult); } var receivedArray = _buffer.Take(receiveResult.Count).ToArray(); totalReceived.AddRange(receivedArray); } while (!receiveResult.EndOfMessage); var split = SplitByZero(totalReceived.ToArray()); foreach (var piece in split) { _logger.LogRaw(piece); var item = new ReceivedItem(piece); result.Add(item); } return(result); }