Exemple #1
0
        private void btnSaveEquipment_Click(object sender, EventArgs e)
        {
            lblEquipmentID.Text = null;
            DataRow newEquipmentRow = DM.dtEquipment.NewRow();

            if (txtAddDescription.Text == "")
            {
                MessageBox.Show("You must type in an Equipment description.", "Error");
            }
            else
            {
                newEquipmentRow["Description"] = txtAddDescription.Text;
                DM.dtEquipment.Rows.Add(newEquipmentRow);
                MessageBox.Show("Equipment added successfully.", "Success");
                DM.UpdateEquipment();
            }

            return;
        }
Exemple #2
0
        private void btnDeleteEquipment_Click(object sender, EventArgs e)
        {
            DataRow deleteEquipmentRow = DM.dtEquipment.Rows[currencyManager.Position];

            DataRow[] ServiceTypeRow = DM.dtServiceTypeEquipment.Select("EquipmentID =" + txtEquipmentID.Text);
            if (ServiceTypeRow.Length != 0)
            {
                MessageBox.Show("You may only delete equipment that is not allocated to a service type", "Error");
                return;
            }
            else
            {
                if (MessageBox.Show("Are you sure want to delete this record?", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    deleteEquipmentRow.Delete();
                    DM.UpdateEquipment();
                    MessageBox.Show("Item of equipment deleted successfully", "Success");
                    return;
                }
            }
        }