예제 #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (CValidar.ValidarCliente(tb_nombre, tb_ci, errorIcono, this))
            {
                string time = DateTime.Now.ToString("yyyy_mm_dd hh_mm_ss");


                MClientes cli = new MClientes(0, tb_nombre.Text, tb_ci.Text, tb_direccion.Text, tb_telefono.Text, DateTime.Now);

                if (id_user == 0)
                {
                    if (CCliente.Insertar(cli, this))
                    {
                        botones(false, false, false, true, true);
                        mostrar();
                        habilitar(true);
                        limpiar();
                        id_user = 0;
                    }
                }
                else
                {
                    if (CCliente.Editar(id_user, cli, this))
                    {
                        botones(true, false, false, false, true);
                        mostrar();
                        habilitar(true);
                        limpiar();
                        id_user = 0;
                    }
                }
            }
        }
예제 #2
0
        internal static bool Insertar(MClientes objeto, facturacion.Vistas.VVentas 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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            String ci = cb_ci_nit.Text;

            if (ci == string.Empty)
            {
                cb_ci_nit.Focus();
                MessageBox.Show("El ci no debe esta vacia");
                return;
            }

            String nombre = tb_nombreAp.Text;

            if (nombre == string.Empty)
            {
                tb_nombreAp.Focus();
                MessageBox.Show("El nombre no debe esta vacia");
                return;
            }

            MClientes cliente = new MClientes(0, nombre, ci, "", "", DateTime.Now);

            if (CCliente.Insertar(cliente, this))
            {
                btn_guardar.Enabled = false;
                mClientesBindingSource.DataSource = CCliente.mostrar();
                this.cb_ci_nit.DataSource         = CCliente.mostrar();;
                cb_ci_nit.Text      = ci;
                tb_nombreAp.Enabled = false;
            }
        }