Beispiel #1
0
        public bool udpdateData(Tranksaksi t, string id_tranksaksi)
        {
            Boolean stat = false;

            try
            {
                konek.Open();
                cmd             = new MySqlCommand();
                cmd.Connection  = konek;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "UPDATE tranksaksi SET tgl_masuk='" + t.tgl_masuk + "'," +
                                  "tgl_keluar='" + t.tgl_keluar + "'," +
                                  "nama_layanan='" + t.nama_layanan + "'," +
                                  "nama_barang='" + t.nama_barang + "'," +
                                  "banyak_barang='" + t.banyak_barang + "'," +
                                  "harga='" + t.harga + "'," +
                                  "total_harga='" + t.total_harga + "'," +
                                  "id_user='******' WHERE id_tranksaksi='" + id_tranksaksi + "'";
                cmd.ExecuteNonQuery();
                stat = true;
                konek.Close();
            }
            catch (MySqlException)
            {
                Console.WriteLine("gagal di update");
            }
            return(stat);
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int a, b;//ubah properties semuanya

            int.TryParse(textBox1.Text, out a);
            int.TryParse(textBox2.Text, out b);
            textBox3.Text = Convert.ToString(a * b);

            Tranksaksi t = new Tranksaksi();

            t.tgl_masuk     = dateTimePicker1.Value.ToString("yyyy/MM/dd");
            t.tgl_keluar    = dateTimePicker2.Value.ToString("yyyy/MM/dd");
            t.nama_layanan  = comboBox1.Text;
            t.nama_barang   = comboBox2.Text;
            t.banyak_barang = textBox1.Text;
            t.harga         = textBox2.Text;
            t.total_harga   = textBox3.Text;
            t.id_user       = comboBox3.Text;

            td.insertData(t);
            lihatSemuaData();
        }
Beispiel #3
0
        public bool insertData(Tranksaksi tf)
        {
            Boolean stat = false;

            try
            {
                konek.Open();
                cmd             = new MySqlCommand();
                cmd.Connection  = konek;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "INSERT INTO tranksaksi (tgl_masuk, tgl_keluar, nama_layanan, nama_barang, " +
                                  "banyak_barang, harga, total_harga, id_user) " +
                                  "VALUES ('" + tf.tgl_masuk + "','" + tf.tgl_keluar + "','" + tf.nama_layanan + "','"
                                  + tf.nama_barang + "','" + tf.banyak_barang + "','" + tf.harga + "','" + tf.total_harga + "','" + tf.id_user + "')";
                cmd.ExecuteNonQuery();
                stat = true;
                konek.Close();
            }
            catch (MySqlException)
            {
                Console.WriteLine("gagal di insert");
            }
            return(stat);
        }