Example #1
0
        public List <income> incomeData()
        {
            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True");

            con.Open();

            MySqlCommand cmd = new MySqlCommand("SELECT * FROM income", con);

            var model = new List <income>();

            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                DateTime dt     = System.DateTime.Parse(rdr["date"].ToString());
                var      income = new income();
                income.id       = int.Parse(rdr["id"].ToString());
                income.date     = dt.ToString("yyyy-MM-dd");
                income.category = rdr["category"].ToString();
                income.cash     = Double.Parse(rdr["cash"].ToString());
                income.pos      = Double.Parse(rdr["pos"].ToString());
                income.total    = Double.Parse(rdr["amount"].ToString());
                model.Add(income);
            }

            return(model);
        }
Example #2
0
        public void deleteIncome(income income)
        {
            MySqlCommand cmd = new MySqlCommand("delete from income where id = @id", con);

            con.Open();
            cmd.Parameters.AddWithValue("@id", income.id);

            cmd.ExecuteNonQuery();
        }
Example #3
0
        public void deleteIncome(income income)
        {
            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True");

            con.Open();

            MySqlCommand cmd = new MySqlCommand("delete from income where id = @id", con);

            cmd.Parameters.AddWithValue("@id", income.id);

            cmd.ExecuteNonQuery();
        }
Example #4
0
        public void incomeInsert(income income)
        {
            MySqlCommand cmd = new MySqlCommand("INSERT INTO income (date, category, cash, pos, amount) VALUES (@date, @category, @cash, @pos, @total)", con);

            con.Open();
            cmd.Parameters.AddWithValue("@date", income.date);
            cmd.Parameters.AddWithValue("@category", income.category);
            cmd.Parameters.AddWithValue("@cash", income.cash);
            cmd.Parameters.AddWithValue("@pos", income.pos);
            cmd.Parameters.AddWithValue("@total", income.total);

            cmd.ExecuteNonQuery();
        }
Example #5
0
        public void incomeEdit(income income)
        {
            MySqlCommand cmd = new MySqlCommand("UPDATE income SET date = @date, category = @category, cash = @cash, pos = @pos, amount = @total WHERE id = @id", con);

            con.Open();
            cmd.Parameters.AddWithValue("@date", income.date);
            cmd.Parameters.AddWithValue("@category", income.category);
            cmd.Parameters.AddWithValue("@cash", income.cash);
            cmd.Parameters.AddWithValue("@pos", income.pos);
            cmd.Parameters.AddWithValue("@total", income.total);
            cmd.Parameters.AddWithValue("@id", income.id);

            cmd.ExecuteNonQuery();
        }
Example #6
0
        public void incomeInsert(income income)
        {
            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True");

            con.Open();

            MySqlCommand cmd = new MySqlCommand("INSERT INTO income (date, category, cash, pos, amount) VALUES (@date, @category, @cash, @pos, @total)", con);

            cmd.Parameters.AddWithValue("@date", income.date);
            cmd.Parameters.AddWithValue("@category", income.category);
            cmd.Parameters.AddWithValue("@cash", income.cash);
            cmd.Parameters.AddWithValue("@pos", income.pos);
            cmd.Parameters.AddWithValue("@total", income.total);

            cmd.ExecuteNonQuery();
        }
Example #7
0
        public void incomeEdit(income income)
        {
            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=inventorymgt;password=password;allowuservariables=True");

            con.Open();

            MySqlCommand cmd = new MySqlCommand("UPDATE income SET date = @date, category = @category, cash = @cash, pos = @pos, amount = @total WHERE id = @id", con);

            cmd.Parameters.AddWithValue("@date", income.date);
            cmd.Parameters.AddWithValue("@category", income.category);
            cmd.Parameters.AddWithValue("@cash", income.cash);
            cmd.Parameters.AddWithValue("@pos", income.pos);
            cmd.Parameters.AddWithValue("@total", income.total);
            cmd.Parameters.AddWithValue("@id", income.id);

            cmd.ExecuteNonQuery();
        }
Example #8
0
        public List <income> incomeData()
        {
            MySqlCommand cmd = new MySqlCommand("SELECT * FROM income", con);

            var model = new List <income>();

            con.Open();
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                DateTime dt     = System.DateTime.Parse(rdr["date"].ToString());
                var      income = new income();
                income.id       = int.Parse(rdr["id"].ToString());
                income.date     = dt.ToString("yyyy-MM-dd");
                income.category = rdr["category"].ToString();
                income.cash     = Double.Parse(rdr["cash"].ToString());
                income.pos      = Double.Parse(rdr["pos"].ToString());
                income.total    = Double.Parse(rdr["amount"].ToString());
                model.Add(income);
            }

            return(model);
        }