private void PayNow_Click(object sender, EventArgs e) { ConfirmOrder confirms = new ConfirmOrder(userSeed.Text); confirms.buyorderlist.Rows.Clear(); if (dataGridView1.Rows.Count > 0) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null) { confirms.buyorderlist.Rows.Add(); confirms.buyorderlist.Rows[i].Cells[0].Value = dataGridView1.Rows[i].Cells[0].Value.ToString(); confirms.buyorderlist.Rows[i].Cells[1].Value = dataGridView1.Rows[i].Cells[1].Value.ToString(); confirms.buyorderlist.Rows[i].Cells[2].Value = dataGridView1.Rows[i].Cells[2].Value.ToString(); confirms.buyorderlist.Rows[i].Cells[3].Value = dataGridView1.Rows[i].Cells[3].Value.ToString(); confirms.buyorderlist.Rows[i].Cells[4].Value = dataGridView1.Rows[i].Cells[4].Value.ToString(); confirms.buyorderlist.Rows[i].Cells[5].Value = dataGridView1.Rows[i].Cells[5].Value.ToString(); } } confirms.ShowDialog(); } else { Alert.ThatShow("There re no Items to Pay", Alert.AlertType.info); } }
private void AddTocart_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(selectedQty.Text) || selectedQty.Text == "Qty.") { Alert.ThatShow("Please fill Qty.", Alert.AlertType.warning); } else if (int.Parse(txtLeftqty.Text) < int.Parse(selectedQty.Text)) { Alert.ThatShow("Not enough product Qty. instock", Alert.AlertType.warning); } else { int rowId = dataGridView1.Rows.Add(); DataGridViewRow row = dataGridView1.Rows[rowId]; row.Cells["id"].Value = Id.ToString(); row.Cells["pname"].Value = NamedProduct.Text; row.Cells["Qty"].Value = selectedQty.Text; row.Cells["Price"].Value = txtRetail.Text; int totals = int.Parse(selectedQty.Text) * int.Parse(txtRetail.Text); row.Cells["Total"].Value = totals; row.Cells["pid"].Value = txtpid.Text; sumqty.Text = ""; panel2.Visible = false; } }
private void BunifuFlatButton2_Click(object sender, EventArgs e) { int sexnumber = 0; MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("UPDATE Users SET sex = @sex, staffphone = @staffphone, address = @address, staffname = @staffname WHERE username= '******'", conn); Object sexcb = gunaComboBox1.SelectedItem; if (sexcb.ToString() == "Nam") { sexnumber = 1; } else { sexnumber = 0; } command.Parameters.Add("@sex", MySqlDbType.Int32).Value = sexnumber; command.Parameters.Add("@staffphone", MySqlDbType.Int32).Value = staffPhone.Text; command.Parameters.Add("@address", MySqlDbType.VarChar).Value = staffAddress.Text; command.Parameters.Add("@staffname", MySqlDbType.VarChar).Value = staffName.Text; if (string.IsNullOrEmpty(staffPhone.Text) || staffPhone.Text == "Your Phone" || string.IsNullOrEmpty(staffAddress.Text) || staffAddress.Text == "Your Address" || string.IsNullOrEmpty(staffName.Text) || staffName.Text == "Your Name") { Alert.ThatShow("PLS Don't Leave Blank", Alert.AlertType.warning); } else if (staffPhone.Text.Length > 11) { Alert.ThatShow("Phone < 11 Nums", Alert.AlertType.warning); } else { ExecMyQuery(command, "Updated Info Successfuly"); } conn.Close(); }
private void BunifuImageButton2_Click(object sender, EventArgs e) { MySqlConnection conn = DBUtils.GetDBConnection(); MySqlCommand command = new MySqlCommand("SELECT * FROM Users WHERE staffid = @staffid", conn); command.Parameters.Add("@staffid", MySqlDbType.VarChar).Value = mid.Text; MySqlDataAdapter adapter = new MySqlDataAdapter(command); DataTable table = new DataTable(); adapter.Fill(table); if (table.Rows.Count <= 0) { Alert.ThatShow("Empty", Alert.AlertType.info); Clear(); } else { mid.Text = table.Rows[0][1].ToString(); mUsername.Text = table.Rows[0][2].ToString(); mPassword.Text = to.EnCrypt(table.Rows[0][3].ToString()); if (table.Rows[0][4].ToString() == "1") { sexCombo.SelectedIndex = 1; } else { sexCombo.SelectedIndex = 2; } mPhone.Text = table.Rows[0][5].ToString(); mAddress.Text = table.Rows[0][6].ToString(); if (table.Rows[0][7].ToString() == "1") { levelCombo.SelectedIndex = 1; } else if (table.Rows[0][7].ToString() == "2") { levelCombo.SelectedIndex = 2; } else if (table.Rows[0][7].ToString() == "3") { levelCombo.SelectedIndex = 3; } else if (table.Rows[0][7].ToString() == "4") { levelCombo.SelectedIndex = 4; } else { levelCombo.SelectedIndex = 5; } byte[] img = (byte[])table.Rows[0][8]; MemoryStream ms = new MemoryStream(img); pictureBox1.Image = Image.FromStream(ms); mStaffname.Text = table.Rows[0][9].ToString(); btnDelete.Enabled = true; btnUpdate.Enabled = true; upPic.Enabled = true; } }
private void BtnUpdate_Click(object sender, EventArgs e) { int sexnumber = 0; int tempstaffid = 0; MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("UPDATE Users SET staffid = @cid,sex = @sex, staffphone = @cphone, address = @caddress, points = @points, staffname = @staffname WHERE id=@id", conn); command.Parameters.Add("@id", MySqlDbType.VarChar).Value = dgvCus.CurrentRow.Cells[0].Value.ToString(); command.Parameters.Add("@cid", MySqlDbType.VarChar).Value = txtcid.Text; using (var cmd = new MySqlCommand("Select staffid from Users WHERE staffid = '" + txtcid.Text + "'", conn)) { string reid = Convert.ToString(cmd.ExecuteScalar()); resultstaffid.Text = reid; if (resultstaffid.Text.Length > 0) { Alert.ThatShow("Customer ID already exists", Alert.AlertType.warning); } else { tempstaffid = 1; } } Object sexcb = boxSex.SelectedItem; if (sexcb.ToString() == "Sex" || sexcb.ToString() == "Nam") { sexnumber = 1; } else { sexnumber = 0; } command.Parameters.Add("@sex", MySqlDbType.VarChar).Value = sexnumber; command.Parameters.Add("@cphone", MySqlDbType.VarChar).Value = txtCphone.Text; command.Parameters.Add("@caddress", MySqlDbType.VarChar).Value = txtCaddress.Text; command.Parameters.Add("@staffname", MySqlDbType.VarChar).Value = txtCname.Text; command.Parameters.Add("@points", MySqlDbType.Int32).Value = txtPoints.Text; if (string.IsNullOrEmpty(txtcid.Text) || txtcid.Text == "Customer ID" || string.IsNullOrEmpty(txtCname.Text) || txtCname.Text == "Customer Name" || string.IsNullOrEmpty(txtCphone.Text) || txtCphone.Text == "Customer Phone" || string.IsNullOrEmpty(txtCaddress.Text) || txtCaddress.Text == "Customer Address" || string.IsNullOrEmpty(txtPoints.Text) || txtPoints.Text == "Points") { Alert.ThatShow("Don't leave blank", Alert.AlertType.warning); } else if (tempstaffid == 1) { ExecMyQuery(command, "Updated Successfully"); } conn.Close(); }
public void ExecMyQuery(MySqlCommand mcomd) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); if (mcomd.ExecuteNonQuery() == 1) { Alert.ThatShow("Submitted successfully", Alert.AlertType.success); } else { Alert.ThatShow("Unable to fulfil your request", Alert.AlertType.error); } conn.Close(); }
public void ExecMyQuery(MySqlCommand mcomd, string msg) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); if (mcomd.ExecuteNonQuery() == 1) { Alert.ThatShow(msg, Alert.AlertType.success); } else { Alert.ThatShow("Error in making Your request!!", Alert.AlertType.error); } conn.Close(); }
private void RegCollab_Click(object sender, EventArgs e) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("INSERT INTO Collaborator (collabname, collabphone, collabaddress, intro,gmail) VALUES (@Collabname,@Collabphone,@Collabaddress,@Intro,@gmail)", conn); command.Parameters.Add("@Collabname", MySqlDbType.VarChar).Value = collabName.Text; command.Parameters.Add("@Collabphone", MySqlDbType.VarChar).Value = collabPhone.Text; command.Parameters.Add("@Collabaddress", MySqlDbType.VarChar).Value = collabAddress.Text; command.Parameters.Add("@Gmail", MySqlDbType.VarChar).Value = txtMail.Text; command.Parameters.Add("@Intro", MySqlDbType.VarChar).Value = txtIntro.Text; string email = txtMail.Text; if (string.IsNullOrEmpty(collabName.Text) || collabName.Text == "Your Name") { Alert.ThatShow("Please enter Name to continue", Alert.AlertType.warning); } else if (string.IsNullOrEmpty(collabPhone.Text) || collabPhone.Text == "Your Phone" || collabPhone.Text.Length > 11) { Alert.ThatShow("Please enter Phone to continue", Alert.AlertType.warning); } else if (string.IsNullOrEmpty(collabAddress.Text) || collabAddress.Text == "Your Address") { Alert.ThatShow("Please enter Address to continue", Alert.AlertType.warning); } else if (string.IsNullOrEmpty(txtMail.Text) || txtMail.Text == "Your G-Mail") { Alert.ThatShow("Please enter GMAIL to continue", Alert.AlertType.warning); } else if (email.LastIndexOf("@") < 1) { Alert.ThatShow("Wrong email format, Check back ", Alert.AlertType.warning); } else if (string.IsNullOrEmpty(txtIntro.Text) || txtIntro.Text == "Introduce Yourself") { Alert.ThatShow("Please enter Intro to continue", Alert.AlertType.warning); } else { ExecMyQuery(command); } conn.Close(); }
private void BunifuFlatButton1_Click(object sender, EventArgs e) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("UPDATE Users SET password = @newpwd WHERE username= '******'", conn); command.Parameters.Add("@newpwd", MySqlDbType.VarChar).Value = to.EnCrypt(bunifuMetroTextbox3.Text); if (bunifuMetroTextbox1.Text != to.DeCrypt(currentPass.Text)) { Alert.ThatShow("The current PWD is incorrect", Alert.AlertType.warning); } else if (bunifuMetroTextbox2.Text != bunifuMetroTextbox3.Text) { Alert.ThatShow("New password doesn't match", Alert.AlertType.warning); } else { ExecMyQuery(command, "Updated Ur Password"); } conn.Close(); }
private void Paynow_Click(object sender, EventArgs e) { int _min = 1111; int _max = 9999; Random _rdm = new Random(); int billrandom = _rdm.Next(_min, _max); MySqlConnection conn = DBUtils.GetDBConnection(); if (string.IsNullOrEmpty(txtadressship.Text) || txtadressship.Text == "Press your Address") { Alert.ThatShow("PLS enter your Address", Alert.AlertType.warning); } else { Alert.ThatShow("Pay Success", Alert.AlertType.success); for (int i = 0; i < buyorderlist.Rows.Count; i++) { conn.Open(); MySqlCommand command = new MySqlCommand("INSERT INTO Salelog (bid, pname, pid, staffid, amount, dofsale, totals, address) VALUES (@bid,@pname,@pid,@staffid,@amount,@dofsale,@totals,@address)", conn); MySqlDataReader myReader; command.Parameters.Add("@bid", MySqlDbType.Int32).Value = billrandom; // bill random command.Parameters.AddWithValue("@pname", buyorderlist.Rows[i].Cells[1].Value); command.Parameters.AddWithValue("@pid", buyorderlist.Rows[i].Cells[5].Value); command.Parameters.AddWithValue("@staffid", getUserSeed.Text); command.Parameters.AddWithValue("@amount", buyorderlist.Rows[i].Cells[2].Value); command.Parameters.AddWithValue("@dofsale", DateTime.Now); command.Parameters.AddWithValue("@totals", buyorderlist.Rows[i].Cells[4].Value); command.Parameters.AddWithValue("@address", txtadressship.Text); myReader = command.ExecuteReader(); while (myReader.Read()) { } conn.Close(); } this.Close(); } }
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(); LoadingToDB ldb = new LoadingToDB(txtuser.Text); // txtuser query.Fill(filldata); if (filldata.Rows[0][0].ToString() == "1") { Alert.ThatShow("Please wait A moment", Alert.AlertType.success); RememberChecked(); ((Form1)this.TopLevelControl).Hide(); ldb.Show(); } else { Alert.ThatShow("Wrong UserName or Password....", Alert.AlertType.warning); } }
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, wholeprice=@wholeprice, retailprice = @retailprice, qty = @qty, 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 = txtProductid.Text; command.Parameters.Add("@pname", MySqlDbType.VarChar).Value = txtProductname.Text; Object typecb = comboType.SelectedItem; command.Parameters.Add("@typename", MySqlDbType.VarChar).Value = typecb.ToString(); Object brandcb = comboBrand.SelectedItem; command.Parameters.Add("@brandname", MySqlDbType.VarChar).Value = brandcb.ToString(); command.Parameters.Add("@wholeprice", MySqlDbType.Int32).Value = txtWholeprice.Text; command.Parameters.Add("@retailprice", MySqlDbType.Int32).Value = txtRetailprice.Text; command.Parameters.Add("@qty", MySqlDbType.Int32).Value = txtQty.Text; command.Parameters.Add("@dateadd", MySqlDbType.DateTime).Value = bunifuDatepicker1.Value; command.Parameters.Add("@image", MySqlDbType.Blob).Value = img; if (string.IsNullOrEmpty(txtProductid.Text) || txtProductid.Text == "Product ID" || string.IsNullOrEmpty(txtProductname.Text) || txtProductname.Text == "Product Name" || comboType.SelectedIndex == 0 || comboBrand.SelectedIndex == 0 || string.IsNullOrEmpty(txtWholeprice.Text) || txtWholeprice.Text == "Wholesale Price" || string.IsNullOrEmpty(txtRetailprice.Text) || txtRetailprice.Text == "Retail Price" || string.IsNullOrEmpty(txtQty.Text) || txtQty.Text == "Qty.") { Alert.ThatShow("Don't leave blank", Alert.AlertType.error); } else { ExecMyQuery(command, "Updated Successfuly"); } conn.Close(); }
public void ExecMyQuery(MySqlCommand mcomd, string msg) { MySqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); if (mcomd.ExecuteNonQuery() == 1) { MailMessage msgg = new MailMessage("*****@*****.**", cMail.Text, "Account Infomation - Guitar Shop", "Here Your UserName: "******" | Password: 123456 (Default Password, Ur Can Change)"); msgg.IsBodyHtml = true; SmtpClient sc = new SmtpClient("smtp.gmail.com", 587); sc.UseDefaultCredentials = false; NetworkCredential cre = new NetworkCredential("*****@*****.**", "0919449012"); sc.Credentials = cre; sc.EnableSsl = true; sc.Send(msgg); Alert.ThatShow(msg, Alert.AlertType.success); this.Close(); } else { Alert.ThatShow("Error in making Your request!!", Alert.AlertType.error); } conn.Close(); }
private void BtnInsert_Click(object sender, EventArgs e) { int tempstaffid = 0; int tempname = 0; 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, wholeprice, retailprice, qty, image, dateadd) VALUES (@pid, @pname, @typename, @brandname, @wholeprice, @retailprice, @qty, @image, @dateadd)", conn); command.Parameters.Add("@pid", MySqlDbType.VarChar).Value = txtProductid.Text; command.Parameters.Add("@pname", MySqlDbType.VarChar).Value = txtProductname.Text; Object typecb = comboType.SelectedItem; command.Parameters.Add("@typename", MySqlDbType.VarChar).Value = typecb.ToString(); Object brandcb = comboBrand.SelectedItem; command.Parameters.Add("@brandname", MySqlDbType.VarChar).Value = brandcb.ToString(); command.Parameters.Add("@wholeprice", MySqlDbType.Int32).Value = txtWholeprice.Text; command.Parameters.Add("@retailprice", MySqlDbType.Int32).Value = txtRetailprice.Text; command.Parameters.Add("@qty", MySqlDbType.Int32).Value = txtQty.Text; command.Parameters.Add("@dateadd", MySqlDbType.DateTime).Value = DateTime.Now; command.Parameters.Add("@image", MySqlDbType.Blob).Value = img; using (var cmd = new MySqlCommand("Select pid from Products WHERE pid = '" + txtProductid.Text + "'", conn)) { string reid = Convert.ToString(cmd.ExecuteScalar()); resultpname.Text = reid; if (resultpname.Text.Length > 0) { Alert.ThatShow("Products ID already exists", Alert.AlertType.warning); } else { tempstaffid = 1; } } using (var cmd1 = new MySqlCommand("Select pname from Products WHERE pid = '" + txtProductname.Text + "'", conn)) { string repname = Convert.ToString(cmd1.ExecuteScalar()); resultpid.Text = repname; if (resultpid.Text.Length > 0) { Alert.ThatShow("Product Name already exists", Alert.AlertType.warning); } else { tempname = 1; } } if (string.IsNullOrEmpty(txtProductid.Text) || txtProductid.Text == "Product ID" || string.IsNullOrEmpty(txtProductname.Text) || txtProductname.Text == "Product Name" || comboType.SelectedIndex == 0 || comboBrand.SelectedIndex == 0 || string.IsNullOrEmpty(txtWholeprice.Text) || txtWholeprice.Text == "Wholesale Price" || string.IsNullOrEmpty(txtRetailprice.Text) || txtRetailprice.Text == "Retail Price" || string.IsNullOrEmpty(txtQty.Text) || txtQty.Text == "Qty.") { Alert.ThatShow("Don't leave blank", Alert.AlertType.error); } else if (tempstaffid == 1 && tempname == 1) { ExecMyQuery(command, "Inserted Successfuly"); } conn.Close(); }
private void BtnUpdate_Click(object sender, EventArgs e) { int levelnumber = 0; int sexnumber = 0; 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 Users SET staffid = @staffid, username = @username, password = @password, sex = @sex, staffphone = @staffphone, address = @address, level = @level, image = @image, staffname = @staffname WHERE id = @id", conn); command.Parameters.Add("@id", MySqlDbType.Int32).Value = dgvUsers.CurrentRow.Cells[0].Value.ToString(); command.Parameters.Add("@staffid", MySqlDbType.VarChar).Value = mid.Text; command.Parameters.Add("@username", MySqlDbType.VarChar).Value = mUsername.Text; string getdatabox = dgvUsers.CurrentRow.Cells[3].Value.ToString(); command.Parameters.Add("@password", MySqlDbType.VarChar).Value = to.EnCrypt(mPassword.Text); Object sexcb = sexCombo.SelectedItem; if (sexcb.ToString() == "Sex" || sexcb.ToString() == "Nam") { sexnumber = 1; } else { sexnumber = 0; } command.Parameters.Add("@sex", MySqlDbType.Int32).Value = sexnumber; command.Parameters.Add("@staffphone", MySqlDbType.Int32).Value = mPhone.Text; command.Parameters.Add("@address", MySqlDbType.VarChar).Value = mAddress.Text; Object selectedItem = levelCombo.SelectedItem; if (selectedItem.ToString() == "Level" || selectedItem.ToString() == "Customer") { levelnumber = 1; } else if (selectedItem.ToString() == "Staff") { levelnumber = 2; } else if (selectedItem.ToString() == "Collaborator") { levelnumber = 3; } else if (selectedItem.ToString() == "Warehouse Checker") { levelnumber = 4; } else { levelnumber = 5; } command.Parameters.Add("@level", MySqlDbType.Int32).Value = levelnumber; command.Parameters.Add("@image", MySqlDbType.Blob).Value = img; command.Parameters.Add("@staffname", MySqlDbType.VarChar).Value = mStaffname.Text; if (string.IsNullOrEmpty(mid.Text) || mid.Text == "Staff ID" || string.IsNullOrEmpty(mUsername.Text) || mUsername.Text == "Username" || string.IsNullOrEmpty(mPassword.Text) || mPassword.Text == "Password" || string.IsNullOrEmpty(mPhone.Text) || mPhone.Text == "Staff Phone" || string.IsNullOrEmpty(mAddress.Text) || mAddress.Text == "Address") { Alert.ThatShow("Don't leave blank", Alert.AlertType.error); } else { ExecMyQuery(command, "Updated Successfully"); } conn.Close(); }
private void BtnInsert_Click(object sender, EventArgs e) { int tempstaffid = 0; int tempuername = 0; int levelnumber = 0; int sexnumber = 0; 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 Users (staffid, username, password, sex, staffphone, address, level, image, staffname) VALUES (@staffid, @username, @password, @sex, @staffphone, @address, @level, @image, @staffname)", conn); command.Parameters.Add("@id", MySqlDbType.Int32).Value = dgvUsers.CurrentRow.Cells[0].Value.ToString(); command.Parameters.Add("@staffid", MySqlDbType.VarChar).Value = mid.Text; command.Parameters.Add("@username", MySqlDbType.VarChar).Value = mUsername.Text; string getdatabox = dgvUsers.CurrentRow.Cells[3].Value.ToString(); command.Parameters.Add("@password", MySqlDbType.VarChar).Value = to.EnCrypt(mPassword.Text); Object sexcb = sexCombo.SelectedItem; if (sexcb.ToString() == "Sex" || sexcb.ToString() == "Nam") { sexnumber = 1; } else { sexnumber = 0; } command.Parameters.Add("@sex", MySqlDbType.Int32).Value = sexnumber; command.Parameters.Add("@staffphone", MySqlDbType.Int32).Value = mPhone.Text; command.Parameters.Add("@address", MySqlDbType.VarChar).Value = mAddress.Text; Object selectedItem = levelCombo.SelectedItem; if (selectedItem.ToString() == "Level" || selectedItem.ToString() == "Customer") { levelnumber = 1; } else if (selectedItem.ToString() == "Staff") { levelnumber = 2; } else if (selectedItem.ToString() == "Collaborator") { levelnumber = 3; } else if (selectedItem.ToString() == "Warehouse Checker") { levelnumber = 4; } else { levelnumber = 5; } command.Parameters.Add("@level", MySqlDbType.Int32).Value = levelnumber; command.Parameters.Add("@image", MySqlDbType.Blob).Value = img; command.Parameters.Add("@staffname", MySqlDbType.VarChar).Value = mStaffname.Text; using (var cmd = new MySqlCommand("Select staffid from Users WHERE staffid = '" + mid.Text + "'", conn)) { string reid = Convert.ToString(cmd.ExecuteScalar()); resultstaffid.Text = reid; if (resultstaffid.Text.Length > 0) { Alert.ThatShow("Staff ID already exists", Alert.AlertType.warning); } else { tempstaffid = 1; } } using (var cmd1 = new MySqlCommand("Select username from Users WHERE username = '******'", conn)) { string reuser = Convert.ToString(cmd1.ExecuteScalar()); resultusername.Text = reuser; if (resultusername.Text.Length > 0) { Alert.ThatShow("Username already exists", Alert.AlertType.warning); } else { tempuername = 1; } } if (string.IsNullOrEmpty(mid.Text) || mid.Text == "Staff ID" || string.IsNullOrEmpty(mUsername.Text) || mUsername.Text == "Username" || string.IsNullOrEmpty(mPassword.Text) || mPassword.Text == "Password" || string.IsNullOrEmpty(mPhone.Text) || mPhone.Text == "Staff Phone" || string.IsNullOrEmpty(mAddress.Text) || mAddress.Text == "Address") { Alert.ThatShow("Don't leave blank", Alert.AlertType.error); } else if (pictureBox1.Image == null) { Alert.ThatShow("Please Import Image", Alert.AlertType.error); } else if (tempstaffid == 1 && tempuername == 1) { ExecMyQuery(command, "Insert Successfully"); } conn.Close(); }
void btn_Click(object sender, EventArgs e) { Button btn_item = sender as Button; NamedProduct.Text = btn_item.Text.ToString(); preNameP.Text = NamedProduct.Text + "xxx"; using (MySqlConnection conn = DBUtils.GetDBConnection()) { conn.Open(); using (var cmd = new MySqlCommand("Select pid,pname,retailprice,qty FROM Products WHERE pname = '" + btn_item.Text.ToString() + "'", conn)) { MySqlDataReader Reader; Reader = cmd.ExecuteReader(); while (Reader.Read()) { string pidd = (string)Reader["pid"]; txtpid.Text = pidd; int retailprice = (int)Reader["retailprice"]; txtRetail.Text = retailprice.ToString(); int qty = (int)Reader["qty"]; txtQty.Text = qty.ToString(); txtLeftqty.Text = qty.ToString(); } if (sumqty.Text != "") { int stock = int.Parse(txtQty.Text) - int.Parse(sumqty.Text); txtLeftqty.Text = stock.ToString(); if (txtLeftqty.Text == "0") { panel2.Visible = false; Alert.ThatShow("OutStock", Alert.AlertType.warning); } } else if (txtQty.Text == "0") { panel2.Visible = false; Alert.ThatShow("OutStock", Alert.AlertType.warning); } else { panel2.Visible = true; } if (preNameP.Text != btn_item.Text.ToString()) { sumqty.Text = ""; } int sum = 0; for (int j = 0; j < dataGridView1.Rows.Count; j++) { if (dataGridView1[1, j].Value.ToString() == btn_item.Text.ToString()) { sum = sum + Convert.ToInt32(dataGridView1[2, j].Value); sumqty.Text = sum.ToString(); } } // int count = Convert.ToInt32(cmd.ExecuteScalar()); // totalusers.Text = count.ToString(); } conn.Close(); } }