private void btn_insave_Click(object sender, EventArgs e) { connection = new MySqlConnection(ConnectionString); if (mtxt_cat.Text == "" || txt_itemname.Text == "" || txt_quant.Text == "" || txt_descrip.Text == "" || txt_serial.Text == "" || mtxt_brand.Text == "" || mcmb_stat.Text == "") { string myStringVariable1 = string.Empty; MetroMessageBox.Show(this, "Field s Empty."); return; } if (IsInserting == true) { connection.Open(); string str = "Select count(*) from inventory_info where item_serial = '" + txt_serial.Text + "' or item_description = '" + txt_descrip.Text + "'"; MySqlCommand cmd = new MySqlCommand(str, connection); int itemExist = Convert.ToInt32(cmd.ExecuteScalar()); if (itemExist > 0) { MetroMessageBox.Show(this, "Item already exist!", "Oopps", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); btn_incancel.PerformClick(); return; } connection.Close(); Insert(); } else { Updates(); } flag_update = 0; InactiveItems items = new InactiveItems(); items.FormClosed += items_FormClosed; }
private void itemname_txt_Click(object sender, EventArgs e) { connection = new MySqlConnection(ConnectionString); InactiveItems iname = new InactiveItems(); if (iname.ShowDialog(this) == DialogResult.OK) { itemname_txt.Text = iname.inactive_grid.Rows[iname.row].Cells[1].Value.ToString(); // itemname_txt.Tag = iname.item_name_grid.Rows[iname.row].Cells[0].Value.ToString(); mtxt_iid.Tag = iname.inactive_grid.Rows[iname.row].Cells[0].Value.ToString(); iname.Active(); } iname.Dispose(); try { connection.Open(); MySqlCommand cmd = new MySqlCommand("select item_name, item_serial from inventory_info where item_name = '" + itemname_txt.Text + "'", connection); MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { mtxt_serial.Text = dataReader["item_serial"] + ""; } connection.Close(); } catch (Exception ex) { MetroMessageBox.Show(this, ex.Message); } }
private void btn_insave_Click(object sender, EventArgs e) { connection = new MySqlConnection(ConnectionString); if (mtxt_cat.Text == "" || txt_itemname.Text == "" || txt_quant.Text == "" || txt_descrip.Text == "" || txt_serial.Text =="" || mtxt_brand.Text == "" || mcmb_stat.Text == "") { string myStringVariable1 = string.Empty; MetroMessageBox.Show(this, "Field s Empty"); return; } if (IsInserting == true) { connection.Open(); string str = "Select count(*) from inventory_info where item_serial = '" + txt_serial.Text + "'"; MySqlCommand cmd = new MySqlCommand(str, connection); int itemExist = Convert.ToInt32(cmd.ExecuteScalar()); if (itemExist > 0) { MetroMessageBox.Show(this, "Item already exist"); btn_incancel.PerformClick(); return; } connection.Close(); Insert(); } else { Updates(); } flag_update = 0; InactiveItems items = new InactiveItems(); items.FormClosed += items_FormClosed; }