Пример #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
    public static string EditarCliente(int IdCliente, string Cliente, int IdMunicipio)
    {
        CObjeto Respuesta = new CObjeto();

        CUnit.Firmado(delegate(CDB Conn)
        {
            string Error      = Conn.Mensaje;
            CSecurity permiso = new CSecurity();
            if (permiso.tienePermiso("puedeEditarCliente"))
            {
                if (Conn.Conectado)
                {
                    CObjeto Datos = new CObjeto();

                    CCliente cCliente    = new CCliente();
                    cCliente.IdCliente   = IdCliente;
                    cCliente.Cliente     = Cliente;
                    cCliente.IdMunicipio = IdMunicipio;
                    Error = ValidarCliente(cCliente);
                    if (Error == "")
                    {
                        int contador = CCliente.ValidaExisteEditar(IdCliente, IdMunicipio, Cliente, Conn);
                        if (contador == 0)
                        {
                            cCliente.Editar(Conn);
                        }
                        else
                        {
                            Error = Error + "<li>Ya existe este cliente en este municipio.</li>";
                        }
                    }

                    Respuesta.Add("Datos", Datos);
                }
                else
                {
                    Error = Error + "<li>" + Conn.Mensaje + "</li>";
                }
            }
            else
            {
                Error = Error + "<li>No tienes los permisos necesarios</li>";
            }
            Respuesta.Add("Error", Error);

            Conn.Cerrar();
        });

        return(Respuesta.ToString());
    }