Beispiel #1
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            var obj = new CarsModel();

            if (CheckInputMasterDataForms())
            {
                obj.Id        = Convert.ToInt32(TbId.Text);
                obj.ModelName = TbModelName.Text;
                obj.ModelYear = Convert.ToInt32(TbModelYear.Text);
                obj.NumberCar = TbCarNumber.Text;
                obj.RentCost  = Convert.ToDecimal(TbRentCost.Text);

                try
                {
                    if (crud.DeleteCar(obj) > 0)
                    {
                        LoadData();
                        SetEmptyForm();
                    }
                    else
                    {
                        MessageBox.Show("Error Delete data");
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error Delete data " + err.Message);
                    throw err;
                }
            }
            else
            {
                MessageBox.Show("Text Box cannot be empty! ");
            }
        }
        public void DeleteCarTest()
        {
            //Arrange
            var bm       = new CRUDProcessors();
            var carmodel = new CarsModel();

            carmodel.Id      = 12; // this ID value on Table data is Refer to Row 11, KIA Car Model
            obj.VarIntOutput = 0;
            //Act
            obj.VarIntOutput = bm.DeleteCar(carmodel);

            //Assert
            Assert.IsTrue(obj.VarIntOutput > 0, "The actual deletion was success on more than 1 row data");

            bm.Dispose();
        }