public List <daily> dailyData() { MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True"); con.Open(); MySqlCommand cmd = new MySqlCommand("SELECT * FROM daily", con); var model = new List <daily>(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { DateTime dt = System.DateTime.Parse(rdr["date"].ToString()); var daily = new daily(); daily.id = int.Parse(rdr["id"].ToString()); daily.date = dt.ToString("yyyy-MM-dd"); daily.category = rdr["category"].ToString(); daily.savings = Double.Parse(rdr["savings"].ToString()); daily.amount = Double.Parse(rdr["amount"].ToString()); model.Add(daily); } return(model); }
public void deleteDaily(daily daily) { con.Open(); MySqlCommand cmd = new MySqlCommand("delete from daily where id = @id", con); cmd.Parameters.AddWithValue("@id", daily.id); cmd.ExecuteNonQuery(); }
public void deleteDaily(daily daily) { MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True"); con.Open(); MySqlCommand cmd = new MySqlCommand("delete from daily where id = @id", con); cmd.Parameters.AddWithValue("@id", daily.id); cmd.ExecuteNonQuery(); }
public void dailyInsert(daily daily) { MySqlCommand cmd = new MySqlCommand("INSERT INTO daily (date, category, savings, amount) VALUES (@date, @category, @savings, @amount)", con); con.Open(); cmd.Parameters.AddWithValue("@date", daily.date); cmd.Parameters.AddWithValue("@category", daily.category); cmd.Parameters.AddWithValue("@savings", daily.savings); cmd.Parameters.AddWithValue("@amount", daily.amount); cmd.ExecuteNonQuery(); }
public void editDaily(daily daily) { MySqlCommand cmd = new MySqlCommand("UPDATE daily SET date = @date, category = @category, savings = @savings, amount = @amount WHERE id = @id", con); con.Open(); cmd.Parameters.AddWithValue("@date", daily.date); cmd.Parameters.AddWithValue("@category", daily.category); cmd.Parameters.AddWithValue("@savings", daily.savings); cmd.Parameters.AddWithValue("@amount", daily.amount); cmd.Parameters.AddWithValue("@id", daily.id); cmd.ExecuteNonQuery(); }
public void dailyInsert(daily daily) { MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True"); con.Open(); MySqlCommand cmd = new MySqlCommand("INSERT INTO daily (date, category, savings, amount) VALUES (@date, @category, @savings, @amount)", con); cmd.Parameters.AddWithValue("@date", daily.date); cmd.Parameters.AddWithValue("@category", daily.category); cmd.Parameters.AddWithValue("@savings", daily.savings); cmd.Parameters.AddWithValue("@amount", daily.amount); cmd.ExecuteNonQuery(); }
public void editDaily(daily daily) { MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True"); con.Open(); MySqlCommand cmd = new MySqlCommand("UPDATE daily SET date = @date, category = @category, savings = @savings, amount = @amount WHERE id = @id", con); cmd.Parameters.AddWithValue("@date", daily.date); cmd.Parameters.AddWithValue("@category", daily.category); cmd.Parameters.AddWithValue("@savings", daily.savings); cmd.Parameters.AddWithValue("@amount", daily.amount); cmd.Parameters.AddWithValue("@id", daily.id); cmd.ExecuteNonQuery(); }
public List <daily> dailyData() { MySqlCommand cmd = new MySqlCommand("SELECT * FROM daily", con); var model = new List <daily>(); con.Open(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { DateTime dt = System.DateTime.Parse(rdr["date"].ToString()); var daily = new daily(); daily.id = int.Parse(rdr["id"].ToString()); daily.date = dt.ToString("yyyy-MM-dd"); daily.category = rdr["category"].ToString(); daily.savings = Double.Parse(rdr["savings"].ToString()); daily.amount = Double.Parse(rdr["amount"].ToString()); model.Add(daily); } return(model); }