Exemple #1
0
        private void cargarArchivoExterno()
        {
            string           fuente  = @"C:\Users\alumno\Desktop\crudDB.csv";
            ClsArchivo       ar      = new ClsArchivo();
            ClsConexion      cnSQL   = new ClsConexion();
            ClsConexionMysql cnMYSQL = new ClsConexionMysql();

            string[] ArregloNotas = ar.LeerArchivo(fuente);
            string   sentencia    = "";
            int      NumeroLinea  = 0;

            foreach (string Linea in ArregloNotas)
            {
                string[] datos = Linea.Split(';');
                if (NumeroLinea > 0)
                {
                    sentencia += $"insert into tb_estudiantes1 values({datos[0]},'{datos[1]}',{datos[2]},{datos[3]},{datos[4]},{datos[5]},'{datos[6]}');\n";
                }
                NumeroLinea++;
            }
            NumeroLinea = 0;
            cnSQL.EjecutaSQLDirecto(sentencia);
            cnMYSQL.EjecutaMYSQLDirecto(sentencia);
        }
Exemple #2
0
        protected void BtnModificar_Click(object sender, EventArgs e)
        {
            if ((int)Session["IdForm"] > 0)
            {
                if (TxtDescripcion.Text != string.Empty)
                {
                    if (BtnModificar.Text == "Modificar")
                    {
                        BtnModificar.Text = "Aceptar";
                        ActivarCampos(true);
                        BtnModificar.OnClientClick = "return confirm('¿Desea realizar la actualización?');";
                    }
                    else
                    {
                        try
                        {
                            Cnx.BaseDatos(Session["D[BX"].ToString(), Session["$VR"].ToString(), Session["V$U@"].ToString(), Session["P@$"].ToString());
                            using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
                            {
                                sqlCon.Open();
                                int Ppal = 0, ing = 0, Mod = 0, Cons = 0, Impr = 0, Elim = 0;

                                if (CkbPpl.Checked == true)
                                {
                                    Ppal = 1;
                                }
                                if (CkbIng.Checked == true)
                                {
                                    ing = 1;
                                }
                                if (CkbMod.Checked == true)
                                {
                                    Mod = 1;
                                }
                                if (CkbCons.Checked == true)
                                {
                                    Cons = 1;
                                }
                                if (CkbImpr.Checked == true)
                                {
                                    Impr = 1;
                                }
                                if (CkbElim.Checked == true)
                                {
                                    Elim = 1;
                                }
                                string Txtsql = "UPDATE TblUsrFormulario SET IngresarF=@ing, ModificarF=@Mod, ConsultarF=@Cons, ImprimirF=@Impr, EliminarF=@Elim, CasoEspeciaLF1=@CE1," +
                                                "CasoEspeciaLF2=@CE2,CasoEspeciaLF3 =@CE3, CasoEspeciaLF4=@CE4, CasoEspeciaLF5=@CE5, CasoEspeciaLF6=@CE6, Principal=@Ppal  WHERE CodIdFormulario=@ID";
                                SqlCommand sqlCmd = new SqlCommand(Txtsql, sqlCon);
                                sqlCmd.Parameters.AddWithValue("@Ppal", Ppal);
                                sqlCmd.Parameters.AddWithValue("@ing", ing);
                                sqlCmd.Parameters.AddWithValue("@Mod", Mod);
                                sqlCmd.Parameters.AddWithValue("@Cons", Cons);
                                sqlCmd.Parameters.AddWithValue("@Impr", Impr);
                                sqlCmd.Parameters.AddWithValue("@Elim", Elim);
                                sqlCmd.Parameters.AddWithValue("@CE1", TxtCE1.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@CE2", TxtCE2.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@CE3", TxtCE3.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@CE4", TxtCE4.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@CE5", TxtCE5.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@CE6", TxtCE6.Text.ToString());
                                sqlCmd.Parameters.AddWithValue("@ID", Session["IdForm"].ToString());

                                sqlCmd.ExecuteNonQuery();
                                sqlCon.Close();
                                BtnModificar.Text = "Modificar";
                                ActivarCampos(false);
                                LimparCampos();
                                BtnModificar.OnClientClick = "";
                                BindData(TxtBusqueda.Text);
                            }
                        }
                        catch (Exception ex)
                        {
                            ScriptManager.RegisterClientScriptBlock(this.UpPanel, UpPanel.GetType(), "IdntificadorBloqueScript", "alert('Error en el proceso de edición')", true);

                            ClsConexion ClsUE = new ClsConexion();
                            ClsUE.UpdateError(Session["C77U"].ToString(), "FrmConfigPantalla", "Update", "0", ex.Message, Session["77Version"].ToString(), Session["77Act"].ToString());
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ClsConexion cn = new ClsConexion();

            cn.consultaTablaDirecta($"insert into [tb_empleados] values({DPI},'{Nombre}',{Edad},'{Puesto}',{Salario},'{Fecha}','{Depto}'");
        }
        public ClsAct()
        {
            ClsConexion obclsConexion = new ClsConexion();

            stConexion = obclsConexion.GetConexion();
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            con = new ClsConexion();

            if (!IsPostBack)
            {
                tbFecha.Text = DateTime.Now.ToString("dd/MM/yyyy");
                cambioDolar  = con.obtenerWebService();
                //  tbFecha.ReadOnly = true;
                tbCambioDolar.Text = cambioDolar.Tables[0].Rows[0][2].ToString();
                num            = con.insertarDua();
                TextBox10.Text = num.Tables[0].Rows[0][0].ToString();

                // string cantidad = num.Tables[0].Rows[0][0].ToString();
                //  int numero = 1 + int.Parse(cantidad);
                //TextBox10.Text = con.insertarDua();


                // string nombre="hola";
                dt = con.obtenerCMregimen();
                DataColumn dc = new DataColumn("descripcion", Type.GetType("System.String"));
                //dc.Expression = "codigo+' '+regimen";
                // dt.Columns.Add(dc);
                //  DropDownList1.DataSource =
                //  DropDownList1.DataTextField = "name";
                // DropDownList1.DataBind();


                DropDownList1.DataSource     = dt.DefaultView;
                DropDownList1.DataTextField  = "descripcion";
                DropDownList1.DataValueField = "codigo";

                // Bind the data to the control.
                DropDownList1.DataBind();

                // Set the default selected item, if desired.
                DropDownList1.SelectedIndex = 1;

                // el que me llena el drop de aduana
                dtA = con.obtenerAduana();
                ddlIdAduana.DataSource    = dtA.DefaultView;
                ddlIdAduana.DataTextField = "descripcion";

                ddlIdAduana.DataValueField = "codigoEntero";
                ddlIdAduana.DataBind();
                ddlIdAduana.SelectedIndex = 0;
                // indica cual en el la ingreso destino
                dtIDestino = con.obtenerAduana();
                ddlIdIngresoDestino.DataSource    = dtIDestino.DefaultView;
                ddlIdIngresoDestino.DataTextField = "descripcion";

                ddlIdIngresoDestino.DataValueField = "codigoEntero";
                ddlIdIngresoDestino.DataBind();
                ddlIdIngresoDestino.SelectedIndex = 0;
                ///transporte

                dtTransporte = con.obtenerTransporte();
                ddlIDTransporte.DataSource    = dtTransporte.DefaultView;
                ddlIDTransporte.DataTextField = "descripcion";

                ddlIDTransporte.DataValueField = "id";
                ddlIDTransporte.DataBind();
                ddlIDTransporte.SelectedIndex = 0;
                //regimen
                // String regimen = ddLRegimen.Text;


                dtRegimen = con.obtenerRegimen();
                DataColumn regimen = new DataColumn("descripcion", Type.GetType("System.String"));

                ddLRegimen.DataSource     = dtRegimen.DefaultView;
                ddLRegimen.DataTextField  = "descripcion";
                ddLRegimen.DataValueField = "codigo";


                ddLRegimen.DataBind();
                ddLRegimen.SelectedIndex = 0;
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            ClsMySQL    cnMySql  = new ClsMySQL();
            ClsConexion cnSql    = new ClsConexion();
            ClsOracle   cnOracle = new ClsOracle();
            int         opcion;

            Console.WriteLine("Ingrese una opcion:\n1.Conectar con SQL server\n2.Conectar con MySql\n3.Conectar con Oracle");
            opcion = int.Parse(Console.ReadLine());
            switch (opcion)
            {
            case 1:
                int selecion;
                Console.WriteLine("Ingrese opcion:\n1. Conectar a SQL Server\n2.Insertar datos\n3. Insertar doc.txt");
                selecion = int.Parse(Console.ReadLine());

                switch (selecion)
                {
                case 1:
                    cnSql.abrirConexion();
                    cnSql.cerrarConexionBD();
                    break;

                case 2:
                    string datos = cnSql.insertar_datos();
                    cnSql.EjecutaSQLDirecto(datos);

                    break;

                case 3:
                    string ob_txt = cnSql.Insert_Registro_txt();
                    cnSql.EjecutaSQLDirecto(ob_txt);
                    break;

                default:
                    Console.WriteLine("Opcion invalida");
                    break;
                }

                break;

            case 2:
                int selecion2;
                Console.WriteLine("Ingrese opcion:\n1. Conectar y comprobar conexion a MySQL\n2.Insertar datos\n3. Insertar doc.txt\n4.Hacer consulta");
                selecion2 = int.Parse(Console.ReadLine());
                switch (selecion2)
                {
                case 1:
                    cnMySql.AbrirBD();
                    cnMySql.CerrarBD();
                    break;

                case 2:
                    string dat = cnMySql.insertarBD();
                    cnMySql.CrudTable(dat);
                    break;

                case 3:
                    string dt_txt = cnMySql.Insert_Registro_txt();
                    cnMySql.CrudTable(dt_txt);
                    break;

                case 4:
                    string consult = "SELECT * FROM tb_alumnos where parcial1>6";
                    cnMySql.consulta_bd(consult);

                    break;

                default:
                    break;
                }
                break;

            case 3:
                int selecion3;
                Console.WriteLine("Ingrese opcion:\n1. Conectar a Oracle\n2.Insertar datos\n3. Insertar doc.txt");
                selecion3 = int.Parse(Console.ReadLine());
                switch (selecion3)
                {
                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
Exemple #7
0
    public string MtdAgregarHabitacion(ClsEHabitacion objECli)
    {
        string        rpta   = "";
        SqlConnection sqlCon = new SqlConnection();

        try
        {
            ClsConexion objcon = new ClsConexion();
            objcon.conectar();
            //1. Establecer la cadena de conexion
            sqlCon.ConnectionString = ClsConexion.ConBDcadena;
            //2. Abrir la conexion de la BD
            sqlCon.Open();
            //3. Establecer el comando
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection  = sqlCon;
            sqlCmd.CommandText = "USP_I_AgregarHabitacion";
            sqlCmd.CommandType = CommandType.StoredProcedure;

            //4. Agregar los parametros al comando
            //Establecemos los valores para el parametro @codigoProducto del Procedimiento Almacenado
            SqlParameter nrohabitacion = new SqlParameter();
            nrohabitacion.ParameterName = "@NroHab";
            nrohabitacion.SqlDbType     = SqlDbType.NVarChar;
            //sqldnicliente.Direction = ParameterDirection.InputOutput;
            nrohabitacion.Size  = 1000;
            nrohabitacion.Value = objECli.NroHabitacion;
            sqlCmd.Parameters.Add(nrohabitacion);     //Agregamos el parametro al comando
                                                      //Establecemos los valores para el parametro @nombre del Procedimiento Almacenado
            SqlParameter sqlPartipohab = new SqlParameter();
            sqlPartipohab.ParameterName = "@TipoHab";
            sqlPartipohab.SqlDbType     = SqlDbType.NVarChar;
            sqlPartipohab.Size          = 100;
            sqlPartipohab.Value         = objECli.TipodeHabitacion;
            sqlCmd.Parameters.Add(sqlPartipohab);     //Agregamos el parametro al comando
                                                      //Establecemos los valores para el parametro @precio del Procedimiento Almacenado
            SqlParameter sqlParaprehab = new SqlParameter();
            sqlParaprehab.ParameterName = "@PreHab";
            sqlParaprehab.SqlDbType     = SqlDbType.NVarChar;
            sqlParaprehab.Size          = 100;
            sqlParaprehab.Value         = objECli.Precio;
            sqlCmd.Parameters.Add(sqlParaprehab);     //Agregamos el parametro al comando

            SqlParameter sqlParLimphab = new SqlParameter();
            sqlParLimphab.ParameterName = "@LimpHab";
            sqlParLimphab.SqlDbType     = SqlDbType.NVarChar;
            sqlParLimphab.Size          = 100;
            sqlParLimphab.Value         = objECli.Limpieza;
            sqlCmd.Parameters.Add(sqlParLimphab);     //Agregamos el parametro al comando

            //Establecemos los valores para el parametro @precio del Procedimiento Almacenado
            SqlParameter sqlParaestad = new SqlParameter();
            sqlParaestad.ParameterName = "@EstaHab";
            sqlParaestad.SqlDbType     = SqlDbType.NVarChar;
            sqlParaestad.Size          = 100;
            sqlParaestad.Value         = objECli.Estado;
            sqlCmd.Parameters.Add(sqlParaestad);

            //5. Ejecutamos el commando
            rpta = sqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se inserto el Cliente de forma correcta";
        }
        catch (Exception ex)
        {
            rpta = ex.Message;
        }
        finally
        {
            //6. Cerramos la conexion con la BD
            if (sqlCon.State == ConnectionState.Open)
            {
                sqlCon.Close();
            }
        }
        return(rpta);
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            detDua     = new dataDetalleDua();
            con        = new ClsConexion();
            duaInicial = new ScDUAInicial();

            //// -------------------------
            if (!IsPostBack)
            {
                /////------------------------------
                dtPaisOrigen                 = detDua.obtenerPaisOrigen();
                ddlPaisOrigen.DataSource     = dtPaisOrigen.DefaultView;
                ddlPaisOrigen.DataTextField  = "descripcion";
                ddlPaisOrigen.DataValueField = "codigo";
                ddlPaisOrigen.DataBind();
                ddlPaisOrigen.SelectedIndex = 0;
                ////--------------------------
                dtPaisOrigen                 = detDua.obtenerPaisOrigen();
                DropDownList1.DataSource     = dtPaisOrigen.DefaultView;
                DropDownList1.DataTextField  = "descripcion";
                DropDownList1.DataValueField = "codigo";
                DropDownList1.DataBind();
                DropDownList1.SelectedIndex = 0;
                ////--------------------------
                dtArribo = detDua.obtenerPuerto();
                DropDownList3.DataSource     = dtArribo.DefaultView;
                DropDownList3.DataTextField  = "descripcion";
                DropDownList3.DataValueField = "codigo";
                DropDownList3.DataBind();
                DropDownList3.SelectedIndex = 0;
                ////--------------------------
                dtArribo = detDua.obtenerPuerto();
                DropDownList2.DataSource     = dtArribo.DefaultView;
                DropDownList2.DataTextField  = "descripcion";
                DropDownList2.DataValueField = "codigo";
                DropDownList2.DataBind();
                DropDownList2.SelectedIndex = 0;
                /////------------------------------arribo
                dtArribo = detDua.obtenerPuerto();
                DropDownList4.DataSource     = dtArribo.DefaultView;
                DropDownList4.DataTextField  = "descripcion";
                DropDownList4.DataValueField = "codigo";
                DropDownList4.DataBind();
                DropDownList4.SelectedIndex = 0;

                /////------------------------------
                dtMoneda = detDua.obtenerMonedas();
                DropDownList5.DataSource     = dtMoneda.DefaultView;
                DropDownList5.DataTextField  = "descripcion";
                DropDownList5.DataValueField = "codigo";
                DropDownList5.DataBind();
                DropDownList5.SelectedIndex = 0;
                /////------------------------------arancelPartida
                arancelPartida               = detDua.obtenerArancelPartidas();
                DropDownList6.DataSource     = arancelPartida.DefaultView;
                DropDownList6.DataTextField  = "descripcion";
                DropDownList6.DataValueField = "codigo";
                DropDownList6.DataBind();
                DropDownList6.SelectedIndex = 0;
                #region /////------------------------------ COND DDE entrega

                /*  arancelPartida = detDua.obtenerCatalogocondicionEntrega();
                 * DropDownList6.DataSource = arancelPartida.DefaultView;
                 * DropDownList6.DataTextField = "descripcion";
                 * DropDownList6.DataValueField = "codigo";
                 * DropDownList6.DataBind();
                 * DropDownList6.SelectedIndex = 0;*/
                #endregion
                #region /////------------------------------ unidad
                dtUnidad = detDua.obtenerUnidades();
                DropDownList7.DataSource     = dtUnidad.DefaultView;
                DropDownList7.DataTextField  = "descripcion";
                DropDownList7.DataValueField = "codigo";
                DropDownList7.DataBind();
                DropDownList7.SelectedIndex = 0;
                #endregion
                #region/////----------------------------- TRATADO CNVENCIONAL


                dtUnidad = detDua.obtenerUnidades();
                DropDownList8.DataSource     = dtUnidad.DefaultView;
                DropDownList8.DataTextField  = "descripcion";
                DropDownList8.DataValueField = "codigo";
                DropDownList8.DataBind();
                DropDownList8.SelectedIndex = 0;
                #endregion
                #region  /////////----------------------------ddlPaisAdq
                dtPaisAdq                 = detDua.obtenerPaisOrigen();
                ddlPaisAdq.DataSource     = dtPaisAdq.DefaultView;
                ddlPaisAdq.DataTextField  = "descripcion";
                ddlPaisAdq.DataValueField = "codigo";
                ddlPaisAdq.DataBind();
                ddlPaisAdq.SelectedIndex = 0;
                #endregion
                #region  ////////--------------------------------  ddlCondEntrega
                DataTable dtCondEntrega;
                dTCondEntrega                 = detDua.obtenerCatalogocondicionEntrega();
                ddlCondEntrega.DataSource     = dTCondEntrega.DefaultView;
                ddlCondEntrega.DataTextField  = "descripc";
                ddlCondEntrega.DataValueField = "codigo";
                ddlCondEntrega.DataBind();
                ddlCondEntrega.SelectedIndex = 0;
                #endregion


                if (Session["s_DuaInicial"] != null)
                {
                    ScDUAInicial dInicial = (ScDUAInicial)Session["s_DuaInicial"];
                    lNumDetalleDua.Text = dInicial.ScNumeroDua.ToString();
                    idModalidad.Text    = dInicial.ScModalidad.ToString();
                    idAduana.Text       = dInicial.ScIdAduana.ToString();
                    tbFechaD.Text       = dInicial.ScFechaDua.ToString();
                    RefrescarGrid(dInicial.listaDetalleDua);
                }
                else
                {
                    Label1.Text = "No cargo ningun producto";
                }
            }
        }