//Update category protected void updateCategory(Label Id, TextBox category, addCategory suspend) { try { conn = new MySqlConnection(this.connection()); conn.Open(); command = new MySqlCommand("UPDATE category SET category_name=@category_name, date_updated=@date_updated WHERE category_id=@id", conn); command.Parameters.AddWithValue("@category_name", category.Text); command.Parameters.AddWithValue("@date_updated", dateNow); command.Parameters.AddWithValue("@id", Id.Text); bool result = (int)command.ExecuteNonQuery() > 0; if (result == true) { MessageBox.Show("Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); suspend.Hide(); } category.Clear(); conn.Close(); command.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Delete category protected void DeleteCategory(Label Id, addCategory suspend) { try { conn = new MySqlConnection(this.connection()); conn.Open(); DialogResult result = MessageBox.Show("Do you want to Delete this item", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { command = new MySqlCommand("DELETE FROM category WHERE category_id = @category_id", conn); command.Parameters.AddWithValue("@category_id", Id.Text); bool check = (int)command.ExecuteNonQuery() > 0; if (check == true) { MessageBox.Show("Deleted Successfully", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information); suspend.Hide(); } conn.Close(); command.Dispose(); } else { MessageBox.Show("Your data is safe", "Safe", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void openaddcat() { if (this.addcat == null) { this.addcat = new addCategory(this) { MdiParent = this }; this.addcat.Show(); } else { this.addcat.WindowState = FormWindowState.Normal; } }
public Central2(string alias) { InitializeComponent(); this.DB = new dbop(); this.MaximizeBox = true; this.Text = "SET SOFTWARE"; this.Shown += this.showINFO; this.FormClosing += onClose; this.DoubleBuffered = true; this.FormBorderStyle = FormBorderStyle.None; this.usr = this.DB.usrget(alias); this.sesion = new login() { idusuario = this.usr.id_usuario, hora_inicio = TimeSpan.Parse(genericDefinitions.getTimeExact()), fecha_inicio = DateTime.Parse(genericDefinitions.getDate()), }; genericDefinitions.globalsesion = this.sesion; this.lblnombreusuario.Text = (this.usr.nombre + " " + this.usr.apellido).ToUpper(); this.lblhorainicio.Text = this.sesion.hora_inicio.ToString(); this.btnusuario.MouseHover += (sender, atgs) => { this.panelSesion.Visible = true; }; this.btnusuario.MouseLeave += (sender, atgs) => { this.panelSesion.Visible = false; }; this.product = null; this.customer = null; this.addcat = null; this.updcat = null; this.delcat = null; this.addpay = null; this.delpay = null; this.updpay = null; this.seepay = null; this.xventa = null; }
public void isDelete(Label Id, addCategory suspend) { this.DeleteCategory(Id, suspend); }
public void update(Label Id, TextBox category, addCategory suspend) { this.updateCategory(Id, category, suspend); }