private void btnSimpan_Click(object sender, EventArgs e)
        {
            connDb.koneksi();

            string KodeBarang = txtKodeBarang.Text;
            string NamaBarang = txtNamaBarang.Text;
            string Satuan     = txtSatuan.Text;
            string Stok       = txtStok.Text;
            string Harga      = txtHarga.Text;

            string sql = "INSERT INTO TBarang (kode_barang,nama_barang,satuan,stok,harga) VALUES(" +
                         "'" + KodeBarang + "','" + NamaBarang + "'," +
                         "'" + Satuan + "','" + Stok + "'," +
                         "'" + Harga + "')";

            cmd = new SqlCommand(sql, connDb.conn);

            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("Data berhasil tersimpan");
                clearText();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data Tidak Berhasil Disimpan" + ex.ToString());
            }
        }
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            connDb.koneksi();

            string IdCustomer   = txtIdCustomer.Text;
            string NamaCustomer = txtNamaCustomer.Text;
            string Alamat       = txtAlamat.Text;
            string Telepon      = txtTelepon.Text;

            string sql = "INSERT INTO TCustomer (id_customer,nama_customer,alamat,telepon) VALUES(" +
                         "'" + IdCustomer + "','" + NamaCustomer + "'," +
                         "'" + Alamat + "','" + Telepon + "')";

            cmd = new SqlCommand(sql, connDb.conn);

            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("Data berhasil tersimpan");
                clearText();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data Tidak Berhasil Disimpan" + ex.ToString());
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            connDb.koneksi();

            try
            {
                string username = txtUsername.Text.Trim();
                string password = txtPassword.Text.Trim();

                string sql = "SELECT * FROM TUser WHERE nama_user='******' and password='******'";
                cmd    = new SqlCommand(sql, connDb.conn);
                reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    FormMaster objFormMaster = new FormMaster();
                    this.Hide();
                    objFormMaster.Show();
                }
                else
                {
                    MessageBox.Show("Username dan Password Salah !!!");
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            connDb.koneksi();

            string IdUser      = txtIdUser.Text;
            string NamaLengkap = txtNamaLengkap.Text;
            string NamaUser    = txtNamaUser.Text;
            string Password    = txtPassword.Text;

            string sql = "INSERT INTO TUser (id_user,nama_lengkap,nama_user,password) VALUES(" +
                         "'" + IdUser + "','" + NamaLengkap + "'," +
                         "'" + NamaUser + "','" + Password + "')";

            cmd = new SqlCommand(sql, connDb.conn);

            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("Data berhasil tersimpan");
                clearText();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data Tidak Berhasil Disimpan" + ex.ToString());
            }
        }
Esempio n. 5
0
        void isiComboID()
        {
            connDb.koneksi();

            try
            {
                string sql = "SELECT id_customer FROM TCustomer";


                cmd = new SqlCommand(sql, connDb.conn);

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    cmbIdCustomer.Items.Add(reader[0]);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }