void GridFill(string SearchValue) { MySqlConnection conn = DBUtils.GetDBConnection(); MySqlCommand gridfill = new MySqlCommand("SELECT * FROM Users WHERE CONCAT(staffid,username,staffphone) LIKE '%" + SearchValue + "%'", conn); MySqlDataAdapter adapter = new MySqlDataAdapter(gridfill); DataTable table = new DataTable(); adapter.Fill(table); dgvUsers.RowTemplate.Height = 30; dgvUsers.AllowUserToAddRows = false; dgvUsers.DataSource = table; DataGridViewImageColumn imgCol = new DataGridViewImageColumn(); imgCol = (DataGridViewImageColumn)dgvUsers.Columns[9]; imgCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dgvUsers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvUsers.Columns[0].Visible = false; }
public void FillGridProducts(string SearchValue) { MySqlConnection conn = DBUtils.GetDBConnection(); MySqlCommand gridfill = new MySqlCommand("SELECT * FROM Products WHERE CONCAT(pid,pname,typename,brandname) LIKE '%" + SearchValue + "%'", conn); MySqlDataAdapter adapter = new MySqlDataAdapter(gridfill); DataTable table = new DataTable(); adapter.Fill(table); dataGridView1.RowTemplate.Height = 60; dataGridView1.AllowUserToAddRows = false; dataGridView1.DataSource = table; DataGridViewImageColumn imgCol = new DataGridViewImageColumn(); imgCol = (DataGridViewImageColumn)dataGridView1.Columns[8]; imgCol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView1.Columns[0].Visible = false; }
void checkaccess(string userhere) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select level from Users WHERE username = '******'"; int userdone = Convert.ToInt32(cmd.ExecuteScalar()); levelvisible.Text = userdone.ToString(); MySqlCommand cmd1 = conn.CreateCommand(); cmd1.CommandText = "Select name FROM Config_levels WHERE level = " + userdone + ""; string typeaccount = Convert.ToString(cmd1.ExecuteScalar()); if (userdone == 1) { label3.Text = typeaccount; label3.ForeColor = Color.White; } else if (userdone == 2) { label3.Text = typeaccount; label3.ForeColor = Color.Yellow; } else if (userdone == 3) { label3.Text = typeaccount; label3.ForeColor = Color.Pink; } else if (userdone == 4) { label3.Text = typeaccount; label3.ForeColor = Color.LightGreen; } else if (userdone == 5) { label3.Text = typeaccount; label3.ForeColor = Color.Crimson; } conn.Close(); }
private void Viewproductstab_Load(object sender, EventArgs e) { using (MySqlConnection conn = DBUtils.GetDBConnection()) { conn.Open(); using (var cmd = new MySqlCommand("SELECT typename FROM Products GROUP BY typename", conn)) { MySqlDataReader myReader; myReader = cmd.ExecuteReader(); List <string> readtypename = new List <string>(); while (myReader.Read()) { readtypename.Add(myReader.GetString(0)); } string[] givetypename = readtypename.ToArray <string>(); foreach (var showtype in givetypename) { bunifuDropdown1.AddItem(showtype); } } using (var cmdbrand = new MySqlCommand("SELECT brandname FROM Products GROUP BY brandname", conn)) { MySqlDataReader myReader1; myReader1 = cmdbrand.ExecuteReader(); List <string> readbrandname = new List <string>(); while (myReader1.Read()) { readbrandname.Add(myReader1.GetString(0)); } string[] givebrandname = readbrandname.ToArray <string>(); foreach (var showbrand in givebrandname) { bunifuDropdown2.AddItem(showbrand); } } conn.Close(); } fillproducts("", ""); }
public void fillproducts(string typename, string brandname) { MySqlConnection conn = DBUtils.GetDBConnection(); MySqlCommand fillprot = new MySqlCommand("SELECT * FROM Products WHERE typename LIKE '%" + typename + "%' AND brandname LIKE '%" + brandname + "%'", conn); MySqlDataAdapter adapter = new MySqlDataAdapter(fillprot); DataTable showproducts = new DataTable(); adapter.Fill(showproducts); fillproductsgridview.RowTemplate.Height = 90; fillproductsgridview.AllowUserToAddRows = false; fillproductsgridview.DataSource = showproducts; DataGridViewImageColumn imgCol = new DataGridViewImageColumn(); imgCol = (DataGridViewImageColumn)fillproductsgridview.Columns[8]; imgCol.ImageLayout = DataGridViewImageCellLayout.Stretch; fillproductsgridview.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; fillproductsgridview.Columns[0].Visible = false; fillproductsgridview.Columns[1].Visible = false; fillproductsgridview.Columns[6].Visible = false; fillproductsgridview.Columns[7].Visible = false; fillproductsgridview.Columns[9].Visible = false; }
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); } }
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(); }
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(); }