Exemplo n.º 1
0
        private void Btninsert_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            MemoryStream ms = new MemoryStream();

            pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
            byte[]       img     = ms.ToArray();
            MySqlCommand command = new MySqlCommand("INSERT INTO Products (pid, pname, typename, brandname, price, cost, amouts, image, dateadd) VALUES (@pid, @pname, @typename, @brandname, @price, @cost, @amouts, @image, @dateadd)", conn);

            command.Parameters.Add("@pid", MySqlDbType.VarChar).Value       = txtpid.Text;
            command.Parameters.Add("@pname", MySqlDbType.VarChar).Value     = txtpname.Text;
            command.Parameters.Add("@typename", MySqlDbType.VarChar).Value  = txttypeid.Text;
            command.Parameters.Add("@brandname", MySqlDbType.VarChar).Value = txtbranddid.Text;
            command.Parameters.Add("@price", MySqlDbType.Int32).Value       = txtprice.Text;
            command.Parameters.Add("@cost", MySqlDbType.Int32).Value        = txtcost.Text;
            command.Parameters.Add("@amouts", MySqlDbType.Int32).Value      = txtamouts.Text;
            command.Parameters.Add("@dateadd", MySqlDbType.DateTime).Value  = bunifuDatepicker1.Value;
            command.Parameters.Add("@image", MySqlDbType.Blob).Value        = img;
            ExecMyQuery(command, "Inserted");
            conn.Close();
        }
Exemplo n.º 2
0
        private void Btnlogin_Click(object sender, EventArgs e)
        {
            string          user = "******"; //txtuser.Text;
            string          pass = "******";  //to.EnCrypt(txtpwd.Text);
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            MySqlDataAdapter query    = new MySqlDataAdapter("select count(*) from Users where username = '******' and password = '******'", conn);
            DataTable        filldata = new DataTable();
            formpanel        panelh   = new formpanel(txtuser.Text);

            query.Fill(filldata);
            if (filldata.Rows[0][0].ToString() == "1")
            {
                MessageBox.Show("Login success!!", "info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ((Form1)this.TopLevelControl).Hide();
                panelh.Show();
            }
            else
            {
                MessageBox.Show("Login Failed", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void Btnupdate_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            MemoryStream ms = new MemoryStream();

            pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
            byte[]       img     = ms.ToArray();
            MySqlCommand command = new MySqlCommand("UPDATE Products SET pid=@pid, pname=@pname, typename=@typename, brandname=@brandname, price=@price, cost = @cost, amouts = @amouts, dateadd = @dateadd, image=@image WHERE id=@id", conn);

            command.Parameters.Add("@id", MySqlDbType.VarChar).Value        = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            command.Parameters.Add("@pid", MySqlDbType.VarChar).Value       = txtpid.Text;
            command.Parameters.Add("@pname", MySqlDbType.VarChar).Value     = txtpname.Text;
            command.Parameters.Add("@typename", MySqlDbType.VarChar).Value  = txttypeid.Text;
            command.Parameters.Add("@brandname", MySqlDbType.VarChar).Value = txtbranddid.Text;
            command.Parameters.Add("@price", MySqlDbType.Int32).Value       = txtprice.Text;
            command.Parameters.Add("@cost", MySqlDbType.Int32).Value        = txtcost.Text;
            command.Parameters.Add("@amouts", MySqlDbType.Int32).Value      = txtamouts.Text;
            command.Parameters.Add("@dateadd", MySqlDbType.DateTime).Value  = bunifuDatepicker1.Value;
            command.Parameters.Add("@image", MySqlDbType.Blob).Value        = img;
            ExecMyQuery(command, "Updated");
            conn.Close();
        }