Beispiel #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (CValidar.ValidarEmpresa(tb_nombre, tb_nit, tb_propietario, errorIcono, this))
            {
                string time = DateTime.Now.ToString("yyyy_mm_dd hh_mm_ss");

                time = time.Replace(" ", "P");
                string dir = "/img/empresa/empresa" + time + ".jpg";
                pb_empresa.Image.Save(@"" + Application.StartupPath + dir, ImageFormat.Jpeg);
                MEmpresa empresa = new MEmpresa(tb_nombre.Text, tb_nit.Text, dir, tb_direccion.Text, tb_telefono.Text, tb_sigla.Text, tb_propietario.Text);
                if (id != 0)
                {
                    if (CEmpresa.Editar(id, empresa, this))
                    {
                        btn_editar.Enabled  = true;
                        btn_guardar.Enabled = false;
                        habilitar(false);
                    }
                }
                else
                {
                    if (CEmpresa.Insertar(empresa, this))
                    {
                        btn_editar.Enabled  = true;
                        btn_guardar.Enabled = false;
                        habilitar(false);
                    }
                }
            }
        }
Beispiel #2
0
    public static string EditarEmpresa(Dictionary <string, object> pEmpresa)
    {
        CConexion ConexionBaseDatos = new CConexion();
        string    respuesta         = ConexionBaseDatos.ConectarBaseDatosSqlServer();

        CEmpresa Empresa = new CEmpresa();

        Empresa.IdEmpresa      = Convert.ToInt32(pEmpresa["IdEmpresa"]);;
        Empresa.RazonSocial    = Convert.ToString(pEmpresa["RazonSocial"]);
        Empresa.Empresa        = Convert.ToString(pEmpresa["Empresa"]);
        Empresa.RFC            = Convert.ToString(pEmpresa["RFC"]);
        Empresa.Telefono       = Convert.ToString(pEmpresa["Telefono"]);
        Empresa.Correo         = Convert.ToString(pEmpresa["Correo"]);
        Empresa.RegimenFiscal  = Convert.ToString(pEmpresa["RegimenFiscal"]);
        Empresa.Dominio        = Convert.ToString(pEmpresa["Dominio"]);
        Empresa.Calle          = Convert.ToString(pEmpresa["Calle"]);
        Empresa.NumeroExterior = Convert.ToString(pEmpresa["NumeroExterior"]);
        Empresa.NumeroInterior = Convert.ToString(pEmpresa["NumeroInterior"]);
        Empresa.Colonia        = Convert.ToString(pEmpresa["Colonia"]);
        Empresa.IdLocalidad    = Convert.ToInt32(pEmpresa["IdLocalidad"]);
        Empresa.CodigoPostal   = Convert.ToString(pEmpresa["CodigoPostal"]);
        Empresa.IdMunicipio    = Convert.ToInt32(pEmpresa["IdMunicipio"]);
        Empresa.Referencia     = Convert.ToString(pEmpresa["Referencia"]);
        Empresa.Logo           = Convert.ToString(pEmpresa["Logo"]);

        string validacion = ValidarEmpresa(Empresa, ConexionBaseDatos);

        JObject oRespuesta = new JObject();

        if (validacion == "")
        {
            Empresa.Editar(ConexionBaseDatos);
            oRespuesta.Add(new JProperty("Error", 0));
            ConexionBaseDatos.CerrarBaseDatosSqlServer();
        }
        else
        {
            oRespuesta.Add(new JProperty("Error", 1));
            oRespuesta.Add(new JProperty("Descripcion", validacion));
        }
        return(oRespuesta.ToString());
    }