private void Submit_Click(object sender, RoutedEventArgs e) { if (nominal.Text == "") { MessageBox.Show("Please Fill in Nominal"); } else { if (Convert.ToInt32(nominal.Text) < 10000) { MessageBox.Show("Minimum Top Up is Rp10000"); } else { conn.Open(); string query = "select saldo from mh_user where kode_user ='******'"; OracleCommand cmd = new OracleCommand(query, conn); int db = Convert.ToInt32(cmd.ExecuteScalar().ToString()); conn.Close(); int t = db + Convert.ToInt32(nominal.Text); query = "update mh_user set saldo = " + t + " where kode_user = '******'"; cmd = new OracleCommand(query, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); cmd = new OracleCommand("insert into history_emoney values ('', :fk, :emoney, :stat, '','TOP UP')", conn); cmd.Parameters.Add(":fk", kod); cmd.Parameters.Add(":emoney", Convert.ToInt32(nominal.Text)); cmd.Parameters.Add(":stat", 2); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Top Up Success! +Rp" + nominal.Text); if (from == 1) { Buyer b = new Buyer(user, kod); b.Show(); this.Close(); } else if (from == 2) { cartBuyer cb = new cartBuyer(user, kod, kodeHTRANS); cb.Show(); this.Close(); } } } }
private void Back_Click(object sender, RoutedEventArgs e) { if (from == 1) { Buyer b = new Buyer(user, kod); b.Show(); this.Close(); } else if (from == 2) { cartBuyer cb = new cartBuyer(user, kod, kodeHTRANS); cb.Show(); this.Close(); } }
private void Submit_Click(object sender, RoutedEventArgs e) { conn.Open(); trans = conn.BeginTransaction(); string kodeH = ""; try { cmd = new OracleCommand() { Connection = conn, CommandText = "autogenht", CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new OracleParameter() { Direction = ParameterDirection.ReturnValue, ParameterName = "kodeht", OracleDbType = OracleDbType.Varchar2, Size = 13 }); cmd.ExecuteNonQuery(); kodeH = cmd.Parameters["kodeht"].Value.ToString(); DateTime tanggal_penuh = DateTime.Now; string tanggal = tanggal_penuh.Day.ToString().PadLeft(2, '0') + "-" + tanggal_penuh.Month.ToString().PadLeft(2, '0') + "-" + tanggal_penuh.Year.ToString(); cmd = new OracleCommand("INSERT INTO htrans(kode_htrans,tgl_transaksi,berat,subtotal,fk_pelanggan,status) values(:kode,to_date(:tgl,'DD-MM-YYYY'),:brt,:sub,:beli,0)", conn); cmd.Parameters.Add(":kode", kodeH); cmd.Parameters.Add(":tgl", tanggal); cmd.Parameters.Add(":brt", totalberat); cmd.Parameters.Add(":sub", totalbeli); cmd.Parameters.Add(":beli", kode); cmd.ExecuteNonQuery(); for (int i = 0; i < cart.Rows.Count; i++) { DataRow dr = submitbuy.NewRow(); DataRow dr1 = cart.Rows[i]; dr["fk_htrans"] = kodeH; dr["fk_produk"] = listbeli[i]; dr["jumlah"] = dr1["AMMOUNT"]; dr["harga"] = dr1["PRICE"]; dr["subtotal"] = dr1["SUBTOTAL"]; dr["status"] = 0; submitbuy.Rows.Add(dr); } dabuilder.Update(submitbuy); buildData(); trans.Commit(); conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); trans.Rollback(); conn.Close(); Console.WriteLine(ex.StackTrace); } cartBuyer cb = new cartBuyer(username, kode, kodeH); cb.Show(); this.Close(); }