Exemplo n.º 1
0
 private void getDate(ItemShipment shipment)
 {
     shipment.ArrivalTime  = dateTimePicker1.Value.Date;
     shipment.ExperiedTime = dateTimePicker2.Value.Date;
     shipment.StoreItem    = context.StoreItems.Find(storeItemCombo.SelectedValue);
     shipment.Supplier     = context.Suppliers.Find(suppliersCombo.SelectedValue);
     shipment.Count        = int.Parse(CountText.Text);
 }
Exemplo n.º 2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            ItemShipment shipment = new ItemShipment();

            ClearDefaults();

            if (DataValidation())
            {
                getDate(shipment);

                if (saveBtn.Text == "Create")
                {
                    bool flag = controller.Insert(shipment);

                    if (flag)
                    {
                        MessageBox.Show(null, "Shipment inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //refresh table
                        dataGrid.DataSource = controller.ViewAll();
                    }
                    else
                    {
                        MessageBox.Show(null, "Something went wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    shipment.ID    = int.Parse(IdText.Text);
                    shipment.Count = int.Parse(CountText.Text);
                    bool flag = controller.Update(shipment);

                    if (flag)
                    {
                        MessageBox.Show(null, "Shipment updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //refresh table
                        dataGrid.DataSource = controller.ViewAll();
                    }
                    else
                    {
                        MessageBox.Show(null, "Something went wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show(null, "Please check your input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }