public static bool Editar(int id, MClientes objeto, facturacion.Vistas.VCliente form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); string query001 = "UPDATE " + table + " SET nombre=@nombre,ci=@ci,direccion=@direccion,telefono=@telefono,created_at=@created_at where id=@id;"; Console.WriteLine(query001); MySqlCommand command = new MySqlCommand(query001, SqlCon); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@nombre", objeto.nombre); command.Parameters.AddWithValue("@ci", objeto.ci); command.Parameters.AddWithValue("@direccion", objeto.direccion); command.Parameters.AddWithValue("@telefono", objeto.telefono); command.Parameters.AddWithValue("@created_at", objeto.created_at); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, "El cliente fue Editada Correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "El cliente no pudo ser Editado", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (MySqlException e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }
public static bool Eliminar(int id, facturacion.Vistas.VCliente form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); MySqlCommand command = new MySqlCommand(String.Format("delete from " + table + " where id='" + id + "';"), SqlCon); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, " Cliente eliminado correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "Cliente no se pudo eliminar", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (Exception e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }
public static bool Insertar(MClientes objeto, facturacion.Vistas.VCliente form) { MySqlConnection SqlCon = new MySqlConnection(Conexion.Cn); try { SqlCon.Open(); string query001 = "INSERT INTO " + table + "(nombre,ci,direccion,telefono,created_at) Values(@nombre,@ci,@direccion,@telefono,@created_at)"; MySqlCommand command = new MySqlCommand(query001, SqlCon); command.Parameters.AddWithValue("@nombre", objeto.nombre); command.Parameters.AddWithValue("@ci", objeto.ci); command.Parameters.AddWithValue("@direccion", objeto.direccion); command.Parameters.AddWithValue("@telefono", objeto.telefono); command.Parameters.AddWithValue("@created_at", objeto.created_at); if (command.ExecuteNonQuery() == 1) { ToastNotification.Show(form, "Cliente Creada Correctamente", global::facturacion.Properties.Resources.ok, 3000, (eToastGlowColor.Green), (eToastPosition.TopRight)); SqlCon.Close(); return(true); } else { ToastNotification.Show(form, "Cliente no pudo ser Creada", global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); SqlCon.Close(); return(false); } } catch (MySqlException e) { ToastNotification.Show(form, e.Message, global::facturacion.Properties.Resources.error, 3000, (eToastGlowColor.Red), (eToastPosition.TopLeft)); return(false); } }
internal static bool ValidarCliente(DevComponents.DotNetBar.Controls.TextBoxX tb_nombre, DevComponents.DotNetBar.Controls.TextBoxX tb_ci, System.Windows.Forms.ErrorProvider errorIcono, facturacion.Vistas.VCliente vCliente) { if (tb_nombre.Text == string.Empty) { errorIcono.SetError(tb_nombre, "El nombre del usuario es necesario"); ToastNotification.Show(vCliente, "El nombre del usuario es necesario", global::facturacion.Properties.Resources.Warning_sign, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); return(false); } else { errorIcono.Clear(); } if (tb_ci.Text == string.Empty) { errorIcono.SetError(tb_nombre, "El ci del usuario es necesario"); ToastNotification.Show(vCliente, "El ci del usuario es necesario", global::facturacion.Properties.Resources.Warning_sign, 3000, (eToastGlowColor.Red), (eToastPosition.TopRight)); return(false); } else { errorIcono.Clear(); } return(true); }