public bool altaEntidad(Entidades Entidad, TiposDeEntidad TpoEntidad, Domicilios direccion)
        {
            SqlCommand oCmd = new SqlCommand();

            oCmd.CommandType = CommandType.Text;

            int estado;

            string sEntidad = "INSERT INTO Entidades " +
                              " VALUES(" +
                              direccion.Entidades_idEntidades + ", " +
                              "'" + Entidad.RazonSocial + "', " +
                              +Entidad.idRazonSocial + ", " +
                              "'" + Entidad.cuit + "')";

            oCmd.CommandText = sEntidad;
            oCmd.Connection  = oCn;
            estado           = oCmd.ExecuteNonQuery();

            string sDomicilio = "INSERT INTO Domiclios " +
                                " VALUES(" +
                                direccion.Entidades_idEntidades + ", " +
                                direccion.Entidades_idEntidades + ", " +
                                "'" + direccion.direccion + "', " +
                                +direccion.altura + ", " +
                                +direccion.latitud + ", " +
                                +direccion.longitud + ", " +
                                "'" + direccion.partido + "'," +
                                "'" + direccion.provincia + "', " +
                                "'" + direccion.pais + "')";

            oCmd.CommandText = sEntidad;
            oCmd.Connection  = oCn;
            estado           = oCmd.ExecuteNonQuery();

            string sTpoEntidad = "INSERT INTO TipoEntidad " +
                                 " VALUES(" +
                                 "'" + TpoEntidad.nomnbre + "', " +
                                 "'" + TpoEntidad.descripcion + "')";

            oCmd.CommandText = sEntidad;
            oCmd.Connection  = oCn;
            estado           = oCmd.ExecuteNonQuery();

            return(msgEstado(estado));
        }
Exemple #2
0
        protected void btn_alta_Click(object sender, EventArgs e)
        {
            cCnx oCn = new cCnx();

            oCn.AbrirCn();

            Domicilios     oDom = new Domicilios();
            Entidades      oE   = new Entidades();
            TiposDeEntidad tpo  = new TiposDeEntidad();

            oDom.Entidades_idEntidades = Convert.ToInt16(oCn.listaGetTpoEntidades(DropDownList1.SelectedValue.ToString()));
            oDom.direccion             = txt_dom.Text;
            oDom.altura    = Convert.ToInt16(txt_altura.Text);
            oDom.latitud   = 0;
            oDom.longitud  = 0;
            oDom.partido   = txt_partido.Text;
            oDom.provincia = txt_provicnia.Text;
            oDom.pais      = txt_pais.Text;

            Random rd = new Random();

            oE.cuit        = "20215700469";
            oE.RazonSocial = "Juan Carlos" + rd.Next(1, 99);
            oE.idEntidades = oDom.Entidades_idEntidades;

            tpo.nomnbre     = "Rubro " + rd.Next(1, 99);
            tpo.descripcion = tpo.nomnbre + " - " + rd.Next(1, 99);


            if (oCn.altaEntidad(oE, tpo, oDom))
            {
                mensaje("Alta Realizada con exito!");
            }
            else
            {
                mensaje("¡Error en ingreso!");
            }
        }