Exemplo n.º 1
0
        /// <summary>
        /// 添加用户蔬菜价格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Price_UserDB price_UserDB = new Price_UserDB();
            Price_User   price_User   = new Price_User(comboBox4.Text, Convert.ToDouble(textBox1.Text), Data.User.ID1);

            if (comboBox4.SelectedIndex == -1)
            {
                price_UserDB.add(price_User);
            }
            else
            {
                price_UserDB.Change(price_User);
            }

            MessageBox.Show("标价成功!", "提示", MessageBoxButtons.OK);
        }
Exemplo n.º 2
0
        public int Change(Price_User price)
        {
            mySqlConnection.Open();
            MySqlCommand mySqlCommand = new MySqlCommand();

            mySqlCommand.CommandText = "update price_user set price=@price where VegName=@name and user=@id";
            mySqlCommand.Connection  = mySqlConnection;
            mySqlCommand.Parameters.AddRange(
                new MySqlParameter[] {
                new MySqlParameter("@price", price.Price),
                new MySqlParameter("@name", price.Name),
                new MySqlParameter("@id", price.Userid)
            });
            int a = mySqlCommand.ExecuteNonQuery();

            mySqlConnection.Close();
            return(a);
        }
Exemplo n.º 3
0
        public int add(Price_User price)
        {
            mySqlConnection.Open();
            string       sql          = "insert into price_user (VegName,Price,User) values (@name,@price,@user)";
            MySqlCommand mySqlCommand = new MySqlCommand(sql, mySqlConnection);

            mySqlCommand.Parameters.AddRange(
                new MySqlParameter[]
            {
                new MySqlParameter("@name", price.Name),
                new MySqlParameter("@price", price.Price),
                new MySqlParameter("@user", price.Userid)
            });
            int a = mySqlCommand.ExecuteNonQuery();

            mySqlConnection.Close();
            return(a);
        }