示例#1
0
        public bool AddJenisSubJenis(JenisSubJenis jnsSubJns)
        {
            bool result = false;

            //m4verick - data yang diambil dari UI adalah 'nama' bukan 'id', perlu inner query untuk mengambil id masing-masing
            query = "INSERT INTO jenis_sub_jenis VALUES('" + jnsSubJns.Id_jenis_sub_jenis + "',"+
                "(SELECT id_jenis_barang FROM jenis_barang WHERE nama_jenis = '" + jnsSubJns.Jenis_id_jenis_barang_fk + "'),"+
                "(SELECT id_sub_jenis_barang FROM sub_jenis_barang WHERE nama_sub_jenis = '" + jnsSubJns.Sub_jenis_id_sub_jenis_barang_fk + "'))";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
示例#2
0
        public bool DeleteJenisSubJenis(JenisSubJenis jnsSubJns)
        {
            bool result = false;

            query = "DELETE FROM jenis_sub_jenis WHERE id_jenis_sub_jenis = '" + jnsSubJns.Id_jenis_sub_jenis + "'";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }