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 = "Outward", CustomerName = "N/A", PaymentType = "N/A", Amount = "N/A"
                    };
                    ShipmentLibrary.InsertInwardSingleShipment(si);
                }
                Notification.Show("Shipments registered", Notification.Type.Success);
                Clear();
                inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetOutwardShipmentsAsync();

                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_BulkOutward_Load(object sender, EventArgs e)
        {
            CourierName.Items.Clear();
            CourierName.Items.AddRange(await ShipmentLibrary.GetCourierNamesAsync());
            inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetOutwardShipmentsAsync();

            dg.ClearSelection();
        }
Example #3
0
        private async void Register_Click(object sender, EventArgs e)
        {
            try
            {
                InwardSingleShipment si = new InwardSingleShipment()
                {
                    CourierName = CourierName.Text, Date = ShipmentDate.Value, ItemCondition = "N/A", ItemName = ItemName.Text, Remarks = Remarks.Text, TrackingId = TrackingId.Text, CustomerName = CustomerName.Text, ShipmentType = "Outward", PaymentType = COD.Checked ? "COD" : "Prepaid", Amount = COD.Checked ? CODAmount.Value.ToString() : "N/A"
                };
                ShipmentLibrary.InsertInwardSingleShipment(si);
                Notification.Show("Shipment Registered.", Notification.Type.Success);
                Clear();
                inwardSingleShipmentBindingSource.DataSource = await ShipmentLibrary.GetOutwardShipmentsAsync();

                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);
            }
        }