Пример #1
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            StringBuilder sb     = new StringBuilder();
            bool          IsPass = true;

            if (string.IsNullOrEmpty(textBoxNamaMerek.Text))
            {
                sb.Append("- Nama Merek harus diisi \n");
                IsPass = false;
            }

            if (string.IsNullOrEmpty(textBoxKeterangan.Text))
            {
                sb.Append("- Keterangan harus diisi \n");
                IsPass = false;
            }

            if (!IsPass)
            {
                MessageBox.Show(sb.ToString(), "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var merek = new Merek()
            {
                NamaMerek  = textBoxNamaMerek.Text,
                Keterangan = textBoxKeterangan.Text
            };

            merekService.Post(merek);

            this.ParentForm.dataGridViewMerek.DataSource = merekService.Get();
            this.Dispose();
        }
Пример #2
0
        public int updMerek(Merek m)
        {
            SqlCommand s = new SqlCommand();

            s.CommandType = CommandType.Text;
            s.CommandText = "UPDATE merk SET merk_kend = '" + m.namaMerek + "' where id = '" + m.Id + "' ";
            return(db.ExeNonQuery(s));
        }
Пример #3
0
        public int delMerek(Merek m)
        {
            SqlCommand s = new SqlCommand();

            s.CommandType = CommandType.Text;
            s.CommandText = "DELETE from merk WHERE id = '" + m.Id + "' ";
            return(db.ExeNonQuery(s));
        }
Пример #4
0
        public int insertMerek(Merek m)
        {
            SqlCommand s = new SqlCommand();

            s.CommandType = CommandType.Text;
            s.CommandText = "INSERT INTO merk VALUES('" + m.namaMerek + "')";
            return(db.ExeNonQuery(s));
        }
Пример #5
0
        public DataTable viewMerek(Merek m)
        {
            SqlCommand s = new SqlCommand();

            s.CommandType = CommandType.Text;
            s.CommandText = "SELECT * FROM merk";
            return(db.ExeReader(s));
        }
Пример #6
0
 public void Put(Merek merek)
 {
     merekRepository.Put(merek);
 }
Пример #7
0
 public void Delete(Merek merek)
 {
     merekRepository.Delete(merek);
 }