private void tbSearch_TextChanged(object sender, EventArgs e) { if (tbSearch.Text != "") { DataTable dt = new DataTable(); if (Char.IsLetter(tbSearch.Text[0])) { dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE namaBarang LIKE '%" + tbSearch.Text + "%'"); } else if (Char.IsDigit(tbSearch.Text[0])) { if (tbSearch.Text.Length <= 6) { dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE barangID LIKE '%" + tbSearch.Text + "%'"); } else { dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE barangBarcode LIKE '%" + tbSearch.Text + "%'"); } } if (dt.Rows.Count != 0) { dataGridView1.Rows.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { dataGridView1.Rows.Add(dt.Rows[i]["barangID"].ToString(), dt.Rows[i]["namaBarang"].ToString()); } } } }
private void button1_Click(object sender, EventArgs e) { //CEK DATABASE dt = conn.ExecuteQuery("SELECT * FROM MsEmployee WHERE EmployeeID = '" + tbUser.Text + "' AND Password = '******'"); if (dt.Rows.Count == 1) { main.SetMessage("WELCOME, " + dt.Rows[0]["employeeName"].ToString()); DialogResult = DialogResult.OK; this.Close(); } else if (dt.Rows.Count == 0) { main.SetMessage("User tidak ditemukan"); tbUser.Focus(); tbUser.Select(0, 99); } else { main.SetMessage("Double User, coba kontak boy ya!"); DialogResult = DialogResult.Cancel; this.Close(); } }
private void nmrBarangDiEnter() { try { Int32.Parse(tbNomorBarang.Text); } catch (Exception e) { tbNomorBarang.Text = ""; tbNomorBarang.Focus(); tbNomorBarang.Select(0, 9); return; } price200 = false; if (tbNomorBarang.Text.StartsWith("R") == true && tbNomorBarang.Text.Length == 7) { tbNomorBarang.Text = tbNomorBarang.Text.Substring(1); DataTable dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE barangID = '" + tbNomorBarang.Text + "'"); if (dt.Rows.Count == 1) { addBarangToEditing(dt); } else { activeBarcode = ""; tbNomorBarang.Text = ""; tbNomorBarang.Focus(); } } else if (tbNomorBarang.Text.Length > 6) { DataTable dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE barangBarcode = '" + tbNomorBarang.Text + "'"); if (dt.Rows.Count == 1) { addBarangToEditing(dt); } else { activeBarcode = ""; tbNomorBarang.Text = ""; tbNomorBarang.Focus(); } } else if (tbNomorBarang.Text.Length == 6) { DataTable dt = conn.ExecuteQuery("SELECT * FROM MsBarang WHERE barangID = '" + tbNomorBarang.Text + "'"); if (dt.Rows.Count == 1) { addBarangToEditing(dt); } else { activeBarcode = ""; tbNomorBarang.Text = ""; tbNomorBarang.Focus(); } } else { tbNomorBarang.Text = ""; tbNomorBarang.Focus(); } }
private void button1_Click(object sender, EventArgs e) { conn.ExecuteQuery("INSERT INTO MsBarang VALUES('" + tbNomorBarang.Text + "', '" + textBox1.Text + "', '" + tbNamaBarang.Text + "', " + nudPrice.Value + ", " + 0 + ", 0, '', 0, " + 0 + ", " + textBox2.Text + ", 1)"); RefreshUI(); }