예제 #1
0
    public void btnOk_Click(object sender, EventArgs e)
    {
        //Tomar valores de las cajas de texto
        string id_t   = E_usr.Text;
        string pass_t = entry4.Text;

        if (E_usr.Text == "" || entry4.Text == "")
        {
            E_usr.Text  = "";
            entry4.Text = "";
            SPC.Test pp = new SPC.Test();
            pp.Show();
            //SPC.Error_Ventana Ventana_Error = new SPC.Error_Ventana("NoCaptura");
        }
        else
        {
            var text = "";
            try
            {
                connection.Close();

                //Asignar a una variable que sea un commando
                OracleCommand user = new OracleCommand("USER_PASSW");

                //user.BindByName = true;

                //Al comando agregarle la conexion con la base de datos
                user.Connection = connection;
                //Declarar que es un Procedure guardado
                user.CommandType = System.Data.CommandType.StoredProcedure;

                //Declarar cuales son los parametros y si son entradas o salidas
                OracleParameter rv = new OracleParameter("v_Return", OracleDbType.Varchar2, System.Data.ParameterDirection.ReturnValue);
                //
                OracleParameter r = new OracleParameter("r", OracleDbType.Varchar2, 200, "KATI0", System.Data.ParameterDirection.Input);
                //
                OracleParameter id = new OracleParameter("ID_U", OracleDbType.Varchar2, 200, id_t, System.Data.ParameterDirection.Input);
                //
                OracleParameter pas = new OracleParameter("PASSWORD_U", OracleDbType.Varchar2, 200, pass_t, System.Data.ParameterDirection.Input);

                OracleParameter[] ora_par = { r, id, pas, rv };
                user.Parameters.AddRange(ora_par);

                //Abrir coneccion
                connection.Open();

                //Ejecutar
                user.ExecuteNonQuery();

                //Poner el valor de regreso de la funcion en una variable
                text = (string)((OracleString)(user.Parameters[0].Value)).Value;
                Console.Write(text);
                //Cerrar conexion
                connection.Close();

                //Decidir a que ventana ir
                if (text == "Admin")
                {
                    SPC.Admin_First Ventana = new SPC.Admin_First(this);
                    Ventana.Show();
                    E_usr.Text  = "";
                    entry4.Text = "";
                    this.Hide();
                }
                else if (text == "Opr")
                {
                    SPC.Operador_Informacion Ventana = new SPC.Operador_Informacion(this, E_usr.Text);
                    Ventana.Show();
                    E_usr.Text  = "";
                    entry4.Text = "";
                    this.Hide();
                }
                else if (text == "Ing" || text == "Spr")
                {
                    SPC.Supervisor Ventana = new SPC.Supervisor(this);
                    Ventana.Show();
                    E_usr.Text  = "";
                    entry4.Text = "";
                    this.Hide();
                }
                else
                {
                    E_usr.Text  = "";
                    entry4.Text = "";
                    SPC.Error_Ventana Ventana_Error = new SPC.Error_Ventana("LogIn");
                }
            }
            catch (OracleException error)
            {
                SPC.Error_Ventana Ventana_Error = new SPC.Error_Ventana("ErrorCon");
                Console.Write(error);
            }
        }
    }
예제 #2
0
        public Add_User(String Id, Admin_First Ventana) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            P = Ventana;
            combobox3.AppendText("Spr");
            combobox3.AppendText("Ing");
            combobox3.AppendText("Opr");
            combobox3.AppendText("Admin");



            combobox4.AppendText("Matutino");
            combobox4.AppendText("Vespertino");

            v = Id;
            btn_Ok.Clicked  += new EventHandler(this.btnOk_Click);
            btn_Con.Clicked += new EventHandler(this.btnCon_Click);
            btn_Cnl.Clicked += new EventHandler(this.btnCnl_Click);

            if (v != "")
            {
                try
                {
                    const string     connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=spcprojectdb.cxmd6kjxslqw.us-west-1.rds.amazonaws.com)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=ORCL))); User Id=kyann;Password=Gakd0132;";
                    OracleConnection connection       = new OracleConnection(connectionString);
                    OracleCommand    cmd;

                    connection.Open();

                    string sql = "select ID_SYS, NOMBRE, APELLIDO, PUESTO, TURNO, PASSWORD_ from USUARIO WHERE ID_SYS='" + v.ToString() + "'";
                    Console.WriteLine(sql);
                    cmd             = new OracleCommand(sql, connection);
                    cmd.CommandType = System.Data.CommandType.Text;

                    da = new OracleDataAdapter(cmd);
                    cb = new OracleCommandBuilder(da);
                    ds = new System.Data.DataSet();

                    da.Fill(ds);
                    DataTable de = ds.Tables[0];

                    String id_u1 = "";
                    String id_u2 = "";
                    String id_u3 = "";
                    String id_u4 = "";
                    String id_u5 = "";
                    String id_u6 = "";
                    foreach (DataRow row in de.Rows)
                    {
                        id_u1 = (string)row[0];
                        id_u2 = (string)row[1];
                        id_u3 = (string)row[2];
                        id_u4 = (string)row[3];
                        id_u5 = (string)row[4];
                        id_u6 = (string)row[5];


                        //ListaUsuario.AppendValues(row[0], row[1], row[2]);
                    }
                    e_id.Text       = id_u1;
                    e_nombre.Text   = id_u2;
                    e_apellido.Text = id_u3;
                    //combobox3.;
                    if (id_u4 == "Spr")
                    {
                        combobox3.Active = 2;
                    }
                    else if (id_u4 == "Ing")
                    {
                        combobox3.Active = 1;
                    }
                    else if (id_u4 == "Opr")
                    {
                        combobox3.Active = 0;
                    }
                    else if (id_u4 == "Admin")
                    {
                        combobox3.Active = 3;
                    }

                    if (id_u5 == "Matutino")
                    {
                        combobox3.Active = 1;
                    }
                    else if (id_u5 == "Vespertino")
                    {
                        combobox3.Active = 2;
                    }

                    e_contrasena.Text = id_u6;
                }
                catch (OracleException Error)
                {
                    SPC.Error_Ventana Ventana_Error = new SPC.Error_Ventana("ErrorCon");
                    Console.Write(Error);
                }
            }
        }