private async void Register_Click(object sender, EventArgs e) { if (!(await IsValidTrackingIds())) { error.SetError(TrackingIdCount, "Some tracking ids already exist in database."); return; } else { error.SetError(TrackingIdCount, ""); } try { foreach (var item in TrackingIds) { InwardSingleShipment si = new InwardSingleShipment() { CourierName = CourierName.Text, Date = ShipmentDate.Value, ItemCondition = "N/A", ItemName = "N/A", Remarks = Remarks.Text, TrackingId = item, ShipmentType = "Inward", CustomerName = "N/A", Amount = "N/A", PaymentType = "N/A" }; ShipmentLibrary.InsertInwardSingleShipment(si); } Notification.Show("Registered", Notification.Type.Success); Clear(); inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetInwardShipmentsAsync(); dg.ClearSelection(); } catch (Exception ex) { MessageBox.Show($"Failed to register shipments due to:\nException Type:{ex.GetType()}\nMessage:{ex.Message}", ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void UC_BulkInward_Load(object sender, System.EventArgs e) { CourierName.Items.Clear(); CourierName.Items.AddRange(await ShipmentLibrary.GetCourierNamesAsync()); inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetInwardShipmentsAsync(); dg.ClearSelection(); }
private async void Register_Click(object sender, EventArgs e) { try { InwardSingleShipment si = new InwardSingleShipment() { CourierName = CourierName.Text, Date = ShipmentDate.Value, ItemCondition = ItemCondition.Text, ItemName = ItemName.Text, Remarks = Remarks.Text, TrackingId = TrackingId.Text, ShipmentType = "Inward", CustomerName = "N/A", PaymentType = "N/A", Amount = "N/A" }; ShipmentLibrary.InsertInwardSingleShipment(si); Notification.Show("Shipment registered", Notification.Type.Success); Clear(); inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetInwardShipmentsAsync(); dg.ClearSelection(); } catch (Exception ex) { MessageBox.Show($"Failed to register shipment due to:\nException Type:{ex.GetType()}\nMessage:{ex.Message}", ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }