public void AddTransaksiManual(dataTransaksi dtt) { //string query = string.Format("insert into Transaksi values ({0}, {1}, {2}, {3}, '{4}', '{5}')", dtt.ID_User, dtt.ID_Barang, dtt.ID_Admin, dtt.Total_Harga, dtt.Tanggal_Transaksi, dtt.Status); //dataTransaksi DaTransaksi = new dataTransaksi(); //SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); //SqlCommand cmd = new SqlCommand(query, con); //con.Open(); //cmd.ExecuteNonQuery(); //con.Close(); try { string query = string.Format("insert into Transaksi values ({0}, {1}, {2}, {3}, '{4}', '{5}')", dtt.ID_User, dtt.ID_Barang, dtt.ID_Admin, dtt.Total_Harga, dtt.Tanggal_Transaksi, dtt.Status); dataTransaksi DaTransaksi = new dataTransaksi(); SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); SqlCommand cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { ErrorHandling err = new ErrorHandling(HttpStatusCode.InternalServerError.ToString(), "Owh Terjadi Eror : " + ex.Message); throw new WebFaultException <ErrorHandling>(err, System.Net.HttpStatusCode.InternalServerError); } }
public List <dataTransaksi> GetTransaksi(string idUser) { List <dataTransaksi> list = new List <dataTransaksi>(); SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); SqlCommand cmd = new SqlCommand(" SELECT * FROM Transaksi" + idUser, con); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataTransaksi transaksi = new dataTransaksi(); transaksi.ID_Transaksi = reader.GetInt32(0); transaksi.ID_User = reader.GetInt32(1); transaksi.ID_Barang = reader.GetInt32(2); transaksi.ID_Admin = reader.GetInt32(3); transaksi.Total_Harga = reader.GetInt32(4); //transaksi.Tanggal_Transaksi = reader.GetDateTime(5); transaksi.Status = reader.GetString(6); list.Add(transaksi); } con.Close(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(list); }
//TRANSAKSI public List <dataTransaksi> GetSemuaTransaksi() { List <dataTransaksi> list = new List <dataTransaksi>(); SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); SqlCommand cmd = new SqlCommand("select Transaksi.ID_Transaksi, Pengguna.Nama_User, Barang.Nama_Barang, Admin.Nama_Admin, Transaksi.Tanggal_Transaksi, Transaksi.Total_Harga, Pengguna.Alamat, Transaksi.Status from Transaksi join Pengguna on Transaksi.ID_User = Pengguna.ID_User join Admin on Transaksi.ID_Admin = Admin.ID__Admin join Barang on Transaksi.ID_Barang = barang.ID_Barang", con); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataTransaksi transaksi = new dataTransaksi(); transaksi.ID_Transaksi = reader.GetInt32(0); transaksi.ID_User = reader.GetInt32(1); transaksi.ID_Barang = reader.GetInt32(2); transaksi.ID_Admin = reader.GetInt32(3); transaksi.Total_Harga = reader.GetInt32(4); transaksi.Tanggal_Transaksi = reader.GetString(5); transaksi.Status = reader.GetString(6); list.Add(transaksi); } con.Close(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(list); }
public void UpdateTransaksiManual(dataTransaksi dt) { string query = string.Format("update Transaksi set ID_User={1}, ID_Barang={2}, ID_Admin={3}, Total_Harga={4}, Tanggal_Transaksi='{5}', Status='{6}' where ID_Transaksi={0}", dt.ID_Transaksi, dt.ID_User, dt.ID_Barang, dt.ID_Admin, dt.Total_Harga, dt.Tanggal_Transaksi, dt.Status); dataTransaksi DataTransaksi = new dataTransaksi(); SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); SqlCommand cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
public void AddTransaksi(dataTransaksi dt) { string query = string.Format("insert into Transaksi values ({0},{1},{2},{3},'{4}','{5}')", dt.ID_User, dt.ID_Barang, dt.ID_Admin, dt.Total_Harga, dt.Tanggal_Transaksi, dt.Status); dataBarang DataBarang = new dataBarang(); SqlConnection con = new SqlConnection("Data Source=FESAART-DEKSTOP;Initial Catalog=WCF_Projek-Akhir;Persist Security Info=True;User ID=sa;Password=123456"); SqlCommand cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }