Exemple #1
0
        private void OKbutton_Click(object sender, EventArgs e)
        {
            string orden;

            if (UsersShowForm.getstate() == "change")
            {
                if (passwordbox.Text == "" || newpasstextbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (newpasstextbox.Text == "")
                    {
                        newpasstextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        newpasstextbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }

                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else if (newpasstextbox.Text != repettextbox.Text)
                {
                    repettextbox.BackColor = Color.Red;
                    MessageBox.Show("LOS CAMPOS PARA CAMBIAR LAS CONTRASEÑA DEBEN DE SER IGUALES");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        orden  = "UPDATE users_table SET USER_PASSWORD='******' WHERE USER_NAME='" + UsersShowForm.getdatum()[0] + "' AND USERTIPO='" + UsersShowForm.getdatum()[1] + "' AND ID='" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION='" + UsersShowForm.getdatum()[3] + "';";
                        if (show.ordensql(orden) == true)
                        {
                            MessageBox.Show("CONTRASEÑA CAMBIADA CON EXITO");
                            show = new LoginClass();
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("CONTRASEÑA CAMBIADA");
                            show = new LoginClass();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIFIQUE");
                        passwordbox.BackColor = Color.Red;
                        newpasstextbox.Text   = "";
                        repettextbox.Text     = "";
                        cuenta++;
                        if (cuenta == 3)
                        {
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Maximized;
                            begin.Show();
                            this.Close();
                        }
                    }
                }
            }
            else if (UsersShowForm.getstate() == "edit")
            {
                if (passwordbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else if (passwordbox.Text != repettextbox.Text)
                {
                    repettextbox.BackColor = Color.Red;
                    MessageBox.Show("LAS CONTRASEÑAS DEBEN DE SER IGUALES");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        UserAddForm add = new UserAddForm();
                        add.WindowState = FormWindowState.Maximized;
                        add.Show();
                        DireccionGestor.setcloseshowuser();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIIQUE");
                        passwordbox.BackColor = Color.Red;
                        newpasstextbox.Text   = "";
                        repettextbox.Text     = "";
                        cuenta++;
                        if (cuenta == 3)
                        {
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                    }
                }
            }
            else if (UsersShowForm.getstate() == "delete")
            {
                if (passwordbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        orden  = "DROP TABLE IF EXISTS `" + UsersShowForm.getdatum()[0] + "_employee_table;`";
                        show.ordensql(orden);
                        orden = "DROP TABLE IF EXISTS `" + UsersShowForm.getdatum()[0] + "_student_table;`";
                        show.ordensql(orden);
                        orden = "DROP TABLE IF EXISTS `" + UsersShowForm.getdatum()[0] + "_events_table;`";
                        show.ordensql(orden);
                        orden = "DROP TABLE IF EXISTS `" + UsersShowForm.getdatum()[0] + "_movements_table`;";
                        show.ordensql(orden);
                        orden = "delete from users.users_table WHERE USER_NAME= '" + UsersShowForm.getdatum()[0] + "' AND USERTIPO='" + UsersShowForm.getdatum()[1] + "' AND ID='" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION='" + UsersShowForm.getdatum()[3] + "';";
                        show.ordensql(orden);

                        MessageBox.Show("USUARIO " + UsersShowForm.getdatum()[0] + " ELIMINADO");


                        if (UserAccessForm.getusername() == UsersShowForm.getdatum()[0])
                        {
                            DireccionGestor.setcloseshowuser();
                            UserAccessForm begin = new UserAccessForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                        else
                        {
                            show = new LoginClass();
                            UsersShowForm.setrefresh("refresh");
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIIQUE");
                        cuenta++;
                        if (cuenta == 3)
                        {
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                    }
                }
            }
            else if (UsersShowForm.getstate() == "save")
            {
                if (passwordbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        //some codde heereeee
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIIQUE");
                        cuenta++;
                        if (cuenta == 3)
                        {
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                    }
                }
            }
            else if (UsersShowForm.getstate() == "cargar")
            {
                if (passwordbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        //some codde heereeee
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIIQUE");
                        cuenta++;
                        if (cuenta == 3)
                        {
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                    }
                }
            }
            else if (UsersShowForm.getstate() == "comprobar")
            {
                if (passwordbox.Text == "" || repettextbox.Text == "")
                {
                    if (passwordbox.Text == "")
                    {
                        passwordbox.BackColor = Color.Red;
                    }
                    else
                    {
                        passwordbox.BackColor = Color.Green;
                    }
                    if (repettextbox.Text == "")
                    {
                        repettextbox.BackColor = Color.Red;
                    }
                    else
                    {
                        repettextbox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY DATAOS IMPORTANTES VACIOS");
                }
                else
                {
                    LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    if (show.setConection(userlabel.Text, passwordbox.Text))
                    {
                        cuenta = 0;
                        ShowSubjects.setpaso(true);
                    }
                    else
                    {
                        MessageBox.Show("CONTRASEÑA EQUIVOCADA, POR FAVOR RECTIIQUE");
                        cuenta++;
                        if (cuenta == 3)
                        {
                            ShowSubjects.setpaso(false);
                            MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE EMPEZARA UNA RECTIFICACION DE DATOS");
                            UserSecurityForm begin = new UserSecurityForm();
                            begin.WindowState = FormWindowState.Normal;
                            begin.Show();
                            this.Close();
                        }
                    }
                }


                ///////////////////////////////////
            }
            else
            {
                MessageBox.Show("HA OCURRIDO ALGO DURANTE EL PROCESO");
            }
        }
        private void editbutton_Click(object sender, EventArgs e)
        {
            DireccionGestor.setorigen("editor");

            DireccionGestor.setsombrestatic(namelabel.Text);
            DireccionGestor.setotrostatic(joblabel.Text);
            string        userDataName = UserAccessForm.getusername() + "_employee_table";
            EmployeeClass student      = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string        orden        = "SELECT * FROM " + userDataName + " WHERE `NOMBRE COMPLETO`= '" + namelabel.Text + "' and EDAD = '" + agelabel.Text + "';";

            DireccionGestor.setorigen("editor");
            DireccionGestor.setordensql(orden);
            EmployeeForm studentaddobject = new EmployeeForm();

            studentaddobject.WindowState = FormWindowState.Maximized;
            studentaddobject.Show();
            this.Close();
        }
        private void EmployeeOutForm_Load(object sender, EventArgs e)
        {
            outbutton.Enabled = false;

            EmployeeClass emp = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            //string orden = "SELECT * FROM " + UserAccessForm.getusername() + "_employee_table WHERE `NOMBRE COMPLETO` = '" + namelabel.Text + "';";
            emp.filleverylabel(namelabel, getintimelabel, gottendegreelabel, idbox, fechanacimientolabel, telephonelabel, schedulelabel, joblabel, nacionalitylabel, agelabel, tipomonedalabel, sueldolabel, referenciapersonallabel, telefonoreferencialabel, referencialabel, alergialabel, dolencialabel, medicinalabel, razonmedicinalabel, trabajandolabel, fechasalidalabel, sexolabel, direccionlabel, picturetextbox, emaillabel, DireccionGestor.getordensql());
            if (fechasalidalabel.Text == "" || fechasalidalabel.Text == "00/00/0000")
            {
                fechasalidalabel.Hide();
                titlesalida.Hide();
            }
            else
            {
                fechasalidalabel.Show();
                titlesalida.Show();
            }


            if (picturetextbox.Text != "")
            {
                string path        = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                string combinacion = System.IO.Path.Combine(path, UserAccessForm.getusername());

                string fotopath = System.IO.Path.Combine(combinacion, picturetextbox.Text);

                pictureBox.ImageLocation = fotopath;
            }
        }
        private void findinggrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            editbutton.Enabled = false;
            try {
                string userDataName = UserAccessForm.getusername() + "_employee_table";
                string dato         = this.findinggrid.CurrentCell.Value.ToString();


                namebox.Text = dato;
                string orden = "select * from users_table where `USER_NAME` = '" + dato + "';";

                if (show.fillcombo(tipobox, namebox, orden) == true)
                {
                    datum    = new string[4];
                    datum[0] = namebox.Text;
                    datum[1] = tipobox.Text;
                    datum[2] = LoginClass.getdata()[0];
                    datum[3] = LoginClass.getdata()[1];
                    opcionpanel.Show();
                    namebox.Text = "";
                    tipobox.Text = "";
                }
                else
                {
                    editbutton.Enabled = false;
                }
            }
            catch (NullReferenceException pafh) {
                pafh.ToString();
                editbutton.Enabled = false;
            }

            if (show.ordensql("SELECT USER_NAME FROM USERS_TABLE WHERE `USER_NAME` = '" + namebox.Text + "';"))
            {
                editbutton.Enabled = true;
            }
            else
            {
                editbutton.Enabled = false;
            }
        }
        private void tipobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     orden = "SELECT ID, USER_NAME,USERTIPO,FECHA_CREACION,FECHA_LAST_CONECTION,HORA_LAST_CONECTION FROM users.users_table;";

            if ((tipobox.Text == "" || tipobox.Text == "TODOS"))
            {
                orden = "SELECT ID, USER_NAME,USERTIPO,FECHA_CREACION,FECHA_LAST_CONECTION,HORA_LAST_CONECTION FROM users.users_table;";
            }
            else
            {
                orden = "SELECT ID, USER_NAME,USERTIPO,FECHA_CREACION,FECHA_LAST_CONECTION,HORA_LAST_CONECTION FROM users.users_table where USERTIPO='" + tipobox.Text + "';";
            }



            show.ShowDataGridFound(findinggrid, orden);
            encontradoslabel.Text = show.getcuenta().ToString();
        }
        private void editbutton_Click(object sender, EventArgs e)
        {
            DireccionGestor.setorigen("editor");
            dataout = new string[5];
            LoginClass ver          = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     userDataName = UserAccessForm.getusername() + "_employee_table";

            string orden = "SELECT * FROM " + UserAccessForm.getusername() + "_contacts_table WHERE NOMBRE='" + namecombo.Text + "';";

            if (ver.fillcombos(namecombo, telefonocombo, orden))
            {
                editbutton.Enabled   = true;
                quitarbutton.Enabled = true;

                try
                {
                    dataout[0] = namecombo.Text;
                    dataout[1] = telefonocombo.Text;
                    dataout[2] = LoginClass.getdata()[0];
                    dataout[3] = LoginClass.getdata()[1];
                    dataout[4] = LoginClass.getdata()[2];

                    DireccionGestor.setorigen("editor");
                    addContact add = new addContact();
                    add.WindowState = FormWindowState.Normal;
                    add.Show();
                }
                catch (IndexOutOfRangeException por)
                {
                    por.ToString();
                }
                this.Close();
            }
            else
            {
                editbutton.Enabled   = false;
                quitarbutton.Enabled = false;
            }
        }
Exemple #7
0
        private void addbuttonstrip_Click(object sender, EventArgs e)
        {
            if (DireccionGestor.getorigen() == "inicio")
            {
                if (reasonbox.Text == "" || cuantitybox.Text == "" || explanationbox.Text == "")
                {
                    MessageBox.Show("Hay datos importantes vacios, termine el formulario.");
                    if (reasonbox.Text == "")
                    {
                        reasonbox.BackColor = Color.Red;
                    }
                    else
                    {
                        reasonbox.BackColor = Color.Green;
                    }

                    if (cuantitybox.Text == "")
                    {
                        cuantitybox.BackColor = Color.Red;
                    }
                    else
                    {
                        cuantitybox.BackColor = Color.Green;
                    }

                    if (explanationbox.Text == "")
                    {
                        explanationbox.BackColor = Color.Red;
                    }
                    else
                    {
                        explanationbox.BackColor = Color.Green;
                    }
                }
                else
                {
                    try
                    {
                        string         userDataName = UserAccessForm.getusername() + "_movements_table";
                        MovementsClass save         = new MovementsClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                        double         cuantity     = double.Parse(cuantitybox.Text);
                        string         date         = datebox.Value.Day.ToString() + "/" + datebox.Value.Month.ToString() + "/" + datebox.Value.Year.ToString();
                        string         hour         = horabox.Value.Hour.ToString() + ":" + horabox.Value.Minute.ToString() + ":" + horabox.Value.Second.ToString();



                        DireccionGestor.setotrostatic("refresh");
                        if (save.setProfit(date, hour, reasonbox.Text, cuantity, monedatipo.Text, datebox.Value.Day.ToString(), datebox.Value.Month.ToString()
                                           , datebox.Value.Year.ToString(), horabox.Value.Hour.ToString(), horabox.Value.Minute.ToString(), horabox.Value.Second.ToString(),
                                           explanationbox.Text, fondoorigen.Text, userDataName))
                        {
                            save.OrderID(userDataName);
                            MessageBox.Show("NUEVO INGRESO DE DINERO A LAS " + hour + " HA SIDO REGISTRADO");
                            if (MessageBox.Show("REGISTRAR OTRO INGRESO DE DINERO?", "REGISTRAR", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                save = new MovementsClass();
                                this.Close();
                                IngresosForm menu = new IngresosForm();
                                menu.WindowState = FormWindowState.Normal;
                                menu.Show();
                            }
                            else
                            {
                                save = new MovementsClass();
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("INGRESO DE DINERO A LAS " + hour + " HA SIDO REGISTRADO");
                            if (MessageBox.Show("REGISTRAR OTRO INGRESO DE DINERO?", "REGISTRAR", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                            {
                                save = new MovementsClass();
                                this.Close();
                                IngresosForm menu = new IngresosForm();
                                menu.WindowState = FormWindowState.Normal;
                                menu.Show();
                            }
                            else
                            {
                                save = new MovementsClass();
                                this.Close();
                            }
                        }
                    }
                    catch (FormatException datethis) { MessageBox.Show(datethis.ToString()); }
                    catch (InvalidCastException datethose) { MessageBox.Show(datethose.ToString()); }
                }
            }
            else if (DireccionGestor.getorigen() == "editor")
            {
                if (reasonbox.Text == "" || cuantitybox.Text == "" || explanationbox.Text == "")
                {
                    MessageBox.Show("Hay datos importantes vacios, termine el formulario.");
                    if (reasonbox.Text == "")
                    {
                        reasonbox.BackColor = Color.Red;
                    }
                    else
                    {
                        reasonbox.BackColor = Color.Green;
                    }

                    if (cuantitybox.Text == "")
                    {
                        cuantitybox.BackColor = Color.Red;
                    }
                    else
                    {
                        cuantitybox.BackColor = Color.Green;
                    }

                    if (explanationbox.Text == "")
                    {
                        explanationbox.BackColor = Color.Red;
                    }
                    else
                    {
                        explanationbox.BackColor = Color.Green;
                    }
                }
                else
                {
                    try
                    {
                        string         userDataName = UserAccessForm.getusername() + "_movements_table";
                        MovementsClass save         = new MovementsClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                        double         cuantity     = double.Parse(cuantitybox.Text);
                        string         date         = datebox.Value.Day.ToString() + "/" + datebox.Value.Month.ToString() + "/" + datebox.Value.Year.ToString();
                        string         hour         = horabox.Value.Hour.ToString() + ":" + horabox.Value.Minute.ToString() + ":" + horabox.Value.Second.ToString();

                        //`FECHA DEL MOVIMIENTO` ,`HORA DEL MOVIMIENTO` ,MOTIVO ,INGRESO, `TIPO DE MONEDA`, DIA, MES, AÑO, HORA, MINUTO, SEGUNDO, EXPLICACION, `FORMA DE PAGO` ) values ('" + datemovement + "', '" + timemovement + "' , '" + reasonmovement + "', '" + profit + "','" + tipomoneda + "','" + dia + "','" + mes + "','" + anio + "','" + hora + "','" + minuto + "','" + segundo + "','" + explicacion + "','" + origenfondo + "'

                        DireccionGestor.setotrostatic("refresh");
                        string orden = "UPDATE " + userDataName + " SET `FECHA DEL MOVIMIENTO`='" + date + "',  `HORA DEL MOVIMIENTO`='" + hour + "', MOTIVO='" + reasonbox.Text + "', INGRESO='" + cuantity + "', `TIPO DE MONEDA`='" + monedatipo.Text + "',DIA='" + datebox.Value.Day.ToString() + "', MES='" + datebox.Value.Month.ToString() + "', AÑO='" + datebox.Value.Year.ToString() + "', HORA='" + datebox.Value.Hour.ToString() + "', MINUTO='" + datebox.Value.Minute.ToString() + "', SEGUNDO='" + datebox.Value.Second.ToString() + "', EXPLICACION='" + explanationbox.Text + "', `FORMA DE PAGO`='" + fondoorigen.Text + "' WHERE ID='" + MovementsClass.getdato()[0] + "' AND `FECHA DEL MOVIMIENTO`='" + MovementsClass.getdato()[2] + "' AND  `HORA DEL MOVIMIENTO`='" + MovementsClass.getdato()[3] + "';";
                        save.ordensql(orden);


                        MessageBox.Show("INGRESO DE LAS " + MovementsClass.getdato()[3] + " EL DIA " + MovementsClass.getdato()[2] + " HA SIDO EDITADO");
                        this.Close();
                    }
                    catch (FormatException datethis) { MessageBox.Show(datethis.ToString()); }
                    catch (InvalidCastException datethose) { MessageBox.Show(datethose.ToString()); }
                }
            }
        }
        private void ShowSubjects_Load(object sender, EventArgs e)
        {
            texta.Hide();
            OKbutton.BackColor     = Color.Green;
            cancelbutton.BackColor = Color.Red;
            seguridadpanel.Hide();
            LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table";

            show.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = show.getcuenta().ToString();
            /////////////////////////

            userlabel.Text = UserAccessForm.getusername();
            orden          = "select * from  USERS_TABLE where USER_NAME = '" + userlabel.Text + "';";
            show.fillpic(texta, orden);


            if (texta.Text != "")
            {
                string path        = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                string combinacion = System.IO.Path.Combine(path, "users");
                string fotopath    = System.IO.Path.Combine(combinacion, texta.Text);
                picture.ImageLocation = fotopath;
            }

            ////////////////////////
            orden = "SELECT DISTINCT ASIGNATURA FROM " + UserAccessForm.getusername() + "_subject_table";
            show.Fillcombo(asignaturabox, orden);
            orden = "SELECT DISTINCT ASIGNADO FROM " + UserAccessForm.getusername() + "_subject_table";
            show.Fillcombo(asignadobox, orden);
            editbutton.Enabled     = false;
            eliminarbutton.Enabled = false;
        }
        private void AddSubject_Load(object sender, EventArgs e)
        {
            OKbutton.BackColor         = Color.Green;
            cancelbutton.BackColor     = Color.Red;
            subjectverbutton.BackColor = Color.Blue;

            EmployeeClass ver   = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string        orden = "SELECT `NOMBRE COMPLETO` FROM " + UserAccessForm.getusername() + "_employee_table;";

            ver.FillNameBox(comboasignado, orden);


            if (DireccionGestor.getorigen() == "inicio")
            {
                titlelabel.Text = "AGREGAR ASIGNATURA";
            }
            else if (DireccionGestor.getorigen() == "editor")
            {
                titlelabel.Text = "MODIFICAR ASIGNATURA";
                try {
                    asignaturatextbox.Text   = ShowSubjects.getinfo()[0];
                    comboasignado.Text       = ShowSubjects.getinfo()[1];
                    descripcionbox.Text      = ShowSubjects.getinfo()[2];
                    subjectverbutton.Enabled = false;
                } catch (NullReferenceException epd) { epd.ToString(); }
            }
            else if (DireccionGestor.getorigen() == "buscador")
            {
                titlelabel.Text          = "AGREGAR ASIGNATURA";
                subjectverbutton.Enabled = false;
            }

            ver.FillNameBox(comboasignado, orden);
        }
        private void dataGrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                LoginClass show         = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string     userDataName = UserAccessForm.getusername() + "_subject_table";
                string     dato         = this.dataGrid.CurrentCell.Value.ToString();

                string orden = "select ASIGNATURA from " + userDataName + " where ASIGNATURA = '" + dato + "' or ASIGNADO='" + dato + "';";
                if (show.takedatatable(orden, "ASIGNATURA") != "")
                {
                    orden = "select ASIGNATURA from " + userDataName + " where ASIGNATURA = '" + dato + "' or ASIGNADO='" + dato + "';";
                    asignaturabox.Text = show.takedatatable(orden, "ASIGNATURA");
                    orden            = "select ASIGNADO from " + userDataName + " where ASIGNATURA = '" + dato + "' or ASIGNADO='" + dato + "';";
                    asignadobox.Text = show.takedatatable(orden, "ASIGNADO");
                    orden            = "SELECT DESCRIPCION FROM " + userDataName + " where ASIGNATURA = '" + asignaturabox.Text + "' AND ASIGNADO='" + asignadobox.Text + "';";
                    string descripcion = show.takedatatable(orden, "DESCRIPCION");

                    info    = new string[3];
                    info[0] = asignaturabox.Text;
                    info[1] = asignadobox.Text;
                    info[2] = descripcion;

                    editbutton.PerformClick();
                }
                else
                {
                    eliminarbutton.Enabled = false;
                    editbutton.Enabled     = false;
                    MessageBox.Show("DEBERIA SELECCIONAR EL CAMPO [ASIGNATURA] O ALMENOS EL CAMPO ASIGNADO [ASIGNADO]");
                }
            }
            catch (NullReferenceException pafh) { pafh.ToString(); }
        }
 private void OKbutton_Click(object sender, EventArgs e)
 {
     if (passwordbox.Text == "" || repettextbox.Text == "")
     {
         MessageBox.Show("HAY DATOS CLAVES VACIOS, RECTIFIQUE");
         if (passwordbox.Text == "")
         {
             passwordbox.BackColor = Color.Red;
         }
         else
         {
             passwordbox.BackColor = Color.Green;
         }
         if (repettextbox.Text == "")
         {
             repettextbox.BackColor = Color.Red;
         }
         else
         {
             repettextbox.BackColor = Color.Green;
         }
     }
     else if (passwordbox.Text != repettextbox.Text)
     {
         repettextbox.BackColor = Color.Red;
         MessageBox.Show("LOS CAMPOS SON DIFERENTES, DEBERIAN SER IGUALES PARA VALIDARLOS ");
     }
     else
     {
         LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
         try {
             if (show.setConection(userlabel.Text, passwordbox.Text))
             {
                 string complete = "`" + UserAccessForm.getusername() + "_subject_table`";
                 MessageBox.Show("LA ASIGNATURA " + asignaturabox.Text + " DE " + asignadobox.Text + " HA SIDO ELIMINADA");
                 repettextbox.Text      = "";
                 passwordbox.Text       = "";
                 repettextbox.BackColor = Color.White;
                 passwordbox.BackColor  = Color.White;
                 limpiarbutton.PerformClick();
                 seguridadpanel.Hide();
             }
             else
             {
                 MessageBox.Show("ERROR AL INTRODUCIR LAS CONTRASEÑAS");
                 repettextbox.Text      = "";
                 passwordbox.Text       = "";
                 repettextbox.BackColor = Color.White;
                 passwordbox.BackColor  = Color.White;
                 limpiarbutton.PerformClick();
                 seguridadpanel.Hide();
             }
         } catch (NullReferenceException OPR) {
             OPR.ToString();
             limpiarbutton.PerformClick();
         }
     }
 }
        private void buscarbutton_Click(object sender, EventArgs e)
        {
            LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table;";

            if (asignaturabox.Text == "" && asignadobox.Text == "")
            {
                orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table;";
            }
            if (asignaturabox.Text != "" && asignadobox.Text == "")
            {
                orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table WHERE ASIGNATURA='" + asignaturabox.Text + "';";
            }
            if (asignaturabox.Text == "" && asignadobox.Text != "")
            {
                orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table WHERE ASIGNADO='" + asignadobox.Text + "';";
            }
            if (asignaturabox.Text != "" && asignadobox.Text != "")
            {
                orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table WHERE ASIGNADO='" + asignadobox.Text + "' AND ASIGNATURA='" + asignaturabox.Text + "';";
            }



            show.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = show.getcuenta().ToString();
        }
        private void asignadobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table WHERE ASIGNADO='" + asignadobox.Text + "';";

            show.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = show.getcuenta().ToString();
        }
        private void limpiarbutton_Click(object sender, EventArgs e)
        {
            LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string     orden = "SELECT ASIGNATURA,ASIGNADO,DESCRIPCION FROM " + UserAccessForm.getusername() + "_subject_table";

            show.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text   = show.getcuenta().ToString();
            asignaturabox.Text = "TODOS";
            asignadobox.Text   = "TODOS";
        }
        private void telefonocombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            string     orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table WHERE TELEFONO='" + telefonocombo.Text + "'; ";
            LoginClass ver   = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            ver.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = ver.getcuenta().ToString();
        }
        private void OKbutton_Click(object sender, EventArgs e)
        {
            LoginClass ver;
            string     asign;
            string     orden;
            string     teach;


            if (asignaturatextbox.Text == "" || comboasignado.Text == "" || descripcionbox.Text == "")
            {
                if (asignaturatextbox.Text == "")
                {
                    asignaturatextbox.BackColor = Color.Red;
                }
                else
                {
                    asignaturatextbox.BackColor = Color.Green;
                }
                if (comboasignado.Text == "")
                {
                    comboasignado.BackColor = Color.Red;
                }
                else
                {
                    comboasignado.BackColor = Color.Green;
                }
                if (descripcionbox.Text == "")
                {
                    descripcionbox.BackColor = Color.Red;
                }
                else
                {
                    descripcionbox.BackColor = Color.Green;
                }
            }
            else if (DireccionGestor.getorigen() == "inicio")
            {
                carga pap = new carga();
                pap.WindowState = FormWindowState.Normal;
                pap.Show();
                ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string complete = UserAccessForm.getusername() + "_subject_table";


                orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                asign = ver.takedatatable(orden, "ASIGNATURA");
                orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                teach = ver.takedatatable(orden, "ASIGNADO");
                try
                {
                    if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text))
                    {
                        MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text);
                        pap.Close();
                    }
                    else
                    {
                        ver.AddSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, UserAccessForm.getusername());

                        pap.Close();
                        MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA");
                        ShowSubjects.setchange("modify");
                        this.Close();
                    }
                }
                catch (NullReferenceException PAP)
                {
                    PAP.ToString();
                    pap.Close();
                    MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA");
                    ShowSubjects.setchange("modify");
                    this.Close();
                }
            }

            else if (DireccionGestor.getorigen() == "editor")
            {
                carga pap = new carga();
                pap.WindowState = FormWindowState.Normal;
                pap.Show();
                ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string complete = UserAccessForm.getusername() + "_subject_table";
                orden = "SELECT * FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";

                orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                asign = ver.takedatatable(orden, "ASIGNATURA");
                orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                teach = ver.takedatatable(orden, "ASIGNADO");
                if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text))
                {
                    pap.Close();
                    MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text);
                }
                else
                {
                    orden = "RENAME TABLE `" + LoginClass.getdata()[1] + "_" + UserAccessForm.getusername() + "_evaluation_student_table` TO `" + asignaturatextbox.Text + "_" + UserAccessForm.getusername() + "_evaluation_student_table`;";
                    ver.ordensql(orden);
                    orden = "RENAME TABLE `" + LoginClass.getdata()[1] + "_" + UserAccessForm.getusername() + "_calification_student_table` TO `" + asignaturatextbox.Text + "_" + UserAccessForm.getusername() + "_calification_student_table`;";
                    ver.ordensql(orden);
                    complete = UserAccessForm.getusername() + "_subject_table";
                    ver.editSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, LoginClass.getdata()[1], LoginClass.getdata()[2], UserAccessForm.getusername());
                    pap.Close();
                    MessageBox.Show("ASIGNATURA " + LoginClass.getdata()[1] + " HA SIDO EDITADA");
                    ShowSubjects.setchange("modify");
                    this.Close();
                }
            }
            else if (DireccionGestor.getorigen() == "buscador")
            {
                carga pap = new carga();
                pap.WindowState = FormWindowState.Normal;
                pap.Show();
                ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string complete = UserAccessForm.getusername() + "_subject_table";


                orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                asign = ver.takedatatable(orden, "ASIGNATURA");
                orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';";
                teach = ver.takedatatable(orden, "ASIGNADO");
                try
                {
                    if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text))
                    {
                        MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text);
                        pap.Close();
                    }
                    else
                    {
                        ver.AddSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, UserAccessForm.getusername());
                        MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA");
                        ShowSubjects.setchange("modify");
                        this.Close();
                    }
                }
                catch (NullReferenceException PAP)
                {
                    PAP.ToString();
                    pap.Close();
                    MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA");
                    ShowSubjects.setchange("modify");
                    this.Close();
                }
            }
        }
        private void limpiarbutton_Click(object sender, EventArgs e)
        {
            telefonocombo.Text   = "";
            namecombo.Text       = "";
            editbutton.Enabled   = false;
            quitarbutton.Enabled = false;
            string     orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table;";
            LoginClass ver   = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            ver.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = ver.getcuenta().ToString();
        }
Exemple #18
0
        private void OKbutton_Click(object sender, EventArgs e)
        {
            cuenta = 0;
            carga ca = new carga();

            ca.WindowState = FormWindowState.Normal;
            ca.Show();
            if (DireccionGestor.getorigen() == "inicio")
            {
                if (nombrebox.Text == "" || telefonobox.Text == "")
                {
                    if (nombrebox.Text == "")
                    {
                        nombrebox.BackColor = Color.Red;
                    }
                    else
                    {
                        nombrebox.BackColor = Color.Green;
                    }
                    if (telefonobox.Text == "")
                    {
                        telefonobox.BackColor = Color.Red;
                    }
                    else
                    {
                        telefonobox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY CAMPOS CLAVES VACIOS");
                }
                else
                {
                    if (direccionbox.Text == "")
                    {
                        direccionbox.Text = "NINGUNA";
                    }
                    if (emailbox.Text == "")
                    {
                        emailbox.Text = "NINGUNA";
                    }

                    try
                    {
                        LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                        add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString());
                        MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO");

                        if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                        {
                            add = new LoginClass();


                            this.Close();
                        }
                        else
                        {
                            add = new LoginClass();

                            addContact menu = new addContact();
                            menu.WindowState = FormWindowState.Normal;
                            menu.Show();
                            this.Close();
                        }
                    }
                    catch (FormatException datethis) { datethis.ToString(); }
                }
            }
            else if (DireccionGestor.getorigen() == "editor")
            {
                try
                {
                    LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                    add.ordensql("UPDATE " + UserAccessForm.getusername() + "_contacts_table SET NOMBRE='" + nombrebox.Text + "', TELEFONO='" + telefonobox.Text + "', DIRECCION='" + direccionbox.Text + "', EMAIL='" + emailbox.Text + "' WHERE ID='" + ShowContacts.getdataout()[4] + "';");
                    MessageBox.Show("CONTACTO " + DireccionGestor.getnombrestatic() + " EDITADO");

                    ShowContacts show = new ShowContacts();
                    show.WindowState = FormWindowState.Normal;
                    show.Show();
                    this.Close();
                }
                catch (FormatException datethis) { datethis.ToString(); }
                catch (IndexOutOfRangeException oper) { oper.ToString(); }
            }
            else if (DireccionGestor.getorigen() == "buscador")
            {
                if (nombrebox.Text == "" || telefonobox.Text == "")
                {
                    if (nombrebox.Text == "")
                    {
                        nombrebox.BackColor = Color.Red;
                    }
                    else
                    {
                        nombrebox.BackColor = Color.Green;
                    }
                    if (telefonobox.Text == "")
                    {
                        telefonobox.BackColor = Color.Red;
                    }
                    else
                    {
                        telefonobox.BackColor = Color.Green;
                    }
                    MessageBox.Show("HAY CAMPOS CLAVES VACIOS");
                }
                else
                {
                    if (direccionbox.Text == "")
                    {
                        direccionbox.Text = "NINGUNA";
                    }
                    if (emailbox.Text == "")
                    {
                        emailbox.Text = "NINGUNA";
                    }

                    try
                    {
                        LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                        add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString());
                        MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO");

                        if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                        {
                            add = new LoginClass();

                            ShowContacts ad = new ShowContacts();
                            ad.WindowState = FormWindowState.Normal;
                            ad.Show();
                            this.Close();
                        }
                        else
                        {
                            add = new LoginClass();

                            addContact menu = new addContact();
                            menu.WindowState = FormWindowState.Normal;
                            menu.Show();
                            this.Close();
                        }
                    }
                    catch (FormatException datethis) { datethis.ToString(); }
                }
            }


            ca.Close();
        }
        private void UserAddForm_Load(object sender, EventArgs e)
        {
            picturetextbox.Hide();


            string       path       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string       targetPath = System.IO.Path.Combine(path, "users");
            FuncionClass f          = new FuncionClass();

            try
            {
                dbserver   = f.readperfil(targetPath)[0];
                dbname     = f.readperfil(targetPath)[1];
                dbuser     = f.readperfil(targetPath)[2];
                dbpassword = f.readperfil(targetPath)[3];
                dbport     = f.readperfil(targetPath)[4];
            }
            catch (NullReferenceException er)
            {
                er.ToString();
            }

            f = new FuncionClass(dbserver, dbname, dbuser, dbpassword, dbport);
            titlelabel.Text = "AGREGAR USUARIO";


            if (UsersShowForm.getstate() == "edit")
            {
                repetlabel.Hide();
                passwordsecuritybox.Hide();
                titlelabel.Text = "MODIFICAR USUARIO";
                LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string     orden = "select * from users_table WHERE USER_NAME = '" + UsersShowForm.getdatum()[0] + "' AND USERTIPO = '" + UsersShowForm.getdatum()[1] + "' AND ID = '" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION = '" + UsersShowForm.getdatum()[3] + "'; ";

                show.fillevery(nameBox, passwordbox, usercombo, askbox1, answerbox1, askbox2, answerbox2, askbox3, answerbox3, askbox4, answerbox4, askbox5, answerbox5, picturetextbox, institucionbox, telefonobox, emailbox, orden);
                if (picturetextbox.Text != "")
                {
                    path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    string combinacion = System.IO.Path.Combine(path, UserAccessForm.getusername());

                    string fotopath = System.IO.Path.Combine(combinacion, picturetextbox.Text);
                    pictureBox.ImageLocation = fotopath;
                }
            }
        }
        private void savebuttonstrip_Click(object sender, EventArgs e)
        {
            if (passwordbox.Text == "" || answerbox1.Text == "" || answerbox2.Text == "" || answerbox3.Text == "" || answerbox4.Text == "" || answerbox5.Text == "")
            {
                if (passwordbox.Text == "")
                {
                    passwordbox.BackColor = Color.Red;
                }
                else
                {
                    passwordbox.BackColor = Color.Green;
                }
                if (answerbox1.Text == "")
                {
                    answerbox1.BackColor = Color.Red;
                }
                else
                {
                    answerbox1.BackColor = Color.Green;
                }
                if (answerbox2.Text == "")
                {
                    answerbox2.BackColor = Color.Red;
                }
                else
                {
                    answerbox2.BackColor = Color.Green;
                }
                if (answerbox3.Text == "")
                {
                    answerbox3.BackColor = Color.Red;
                }
                else
                {
                    answerbox3.BackColor = Color.Green;
                }
                if (answerbox4.Text == "")
                {
                    answerbox4.BackColor = Color.Red;
                }
                else
                {
                    answerbox4.BackColor = Color.Green;
                }
                if (answerbox5.Text == "")
                {
                    answerbox5.BackColor = Color.Red;
                }
                else
                {
                    answerbox5.BackColor = Color.Green;
                }
            }
            else
            {
                LoginClass log = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

                if (log.setConectionsecurity(userlabel.Text, passwordbox.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text) == true)
                {
                    count = 0;

                    UsersShowForm begin = new UsersShowForm();
                    begin.WindowState = FormWindowState.Normal;
                    begin.Show();
                    this.Close();
                }
                else
                {
                    problempanel.Show();
                    MessageBox.Show("ERROR AL INTRODUCIR DATOS");
                    if (count == 5)
                    {
                        MessageBox.Show("POR MOTIVOS DE SEGURIDAD SE CERRARA LA APLICACION");
                        this.Dispose();
                        Application.Exit();
                    }
                    count++;
                }
            }
        }
        public UsersShowForm()
        {
            InitializeComponent();
            LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            show.ShowDataGrid(findinggrid);
            encontradoslabel.Text = show.getcuenta().ToString();
            show.FillFieldsForm(namebox);
        }
        private void UserSecurityForm_Load(object sender, EventArgs e)
        {
            picturetext.Hide();
            string dbserver   = "";
            string dbname     = "";
            string dbuser     = "";
            string dbpassword = "";
            string dbport     = "";

            string       path       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string       targetPath = System.IO.Path.Combine(path, "users");
            FuncionClass f          = new FuncionClass();

            try
            {
                dbserver   = f.readperfil(targetPath)[0];
                dbname     = f.readperfil(targetPath)[1];
                dbuser     = f.readperfil(targetPath)[2];
                dbpassword = f.readperfil(targetPath)[3];
                dbport     = f.readperfil(targetPath)[4];
            }
            catch (NullReferenceException er)
            {
                er.ToString();
            }

            f = new FuncionClass(dbserver, dbname, dbuser, dbpassword, dbport);



            LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            try
            {
                string orden = "select * from users_table WHERE USER_NAME = '" + UsersShowForm.getdatum()[0] + "' AND USERTIPO = '" + UsersShowForm.getdatum()[1] + "' AND ID = '" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION = '" + UsersShowForm.getdatum()[3] + "'; ";

                show.fillsecurity(userlabel, asklabel1, asklabel2, asklabel3, asklabel4, asklabel5, picturetext, orden);
                if (picturetext.Text != "")
                {
                    path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    string combinacion = System.IO.Path.Combine(path, UserAccessForm.getusername());

                    string fotopath = System.IO.Path.Combine(combinacion, picturetext.Text);
                    pictureBox.ImageLocation = fotopath;
                }
                problempanel.Hide();
                picturetext.Hide();
            }
            catch (NullReferenceException pad) {
                problempanel.Hide();
                picturetext.Hide();
                pad.ToString();
            }
        }
        private void timera_Tick(object sender, EventArgs e)
        {
            if (refresh == "refresh")
            {
                refresh = "";
                LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                show.ShowDataGrid(findinggrid);
                namebox.Text          = "";
                tipobox.Text          = "";
                encontradoslabel.Text = show.getcuenta().ToString();
            }



            TimeClass timeobject = new TimeClass();

            hourlabelstrip.Text = timeobject.clockshape();
            datelabelstrip.Text = timeobject.dateshape();


            AgendaClass ev = new AgendaClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            string hora       = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
            string fechal     = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString();;
            string fechashort = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString();

            cuenta++;
            if (cuenta == 4000)
            {
                cuenta = 0;
                backstripbutton.PerformClick();
            }
            if (cuenta == 1000)
            {
                opcionpanel.Hide();
            }
        }
        private void buscarbutton_Click(object sender, EventArgs e)
        {
            string orden = "";

            if (namecombo.Text == "")
            {
                orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table WHERE TELEFONO='" + telefonocombo.Text + "';";
            }
            else if (telefonocombo.Text == "")
            {
                orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table WHERE NOMBRE='" + namecombo.Text + "';";
            }
            else
            {
                orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table WHERE NOMBRE='" + namecombo.Text + "' AND TELEFONO='" + telefonocombo.Text + "';";
            }
            LoginClass ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            ver.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text = ver.getcuenta().ToString();
        }
        private void cleanbuttonstrip_Click(object sender, EventArgs e)
        {
            LoginClass show = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            namebox.Text = "TODOS";
            tipobox.Text = "TODOS";
            string orden = "SELECT ID, USER_NAME,USERTIPO,FECHA_CREACION,FECHA_LAST_CONECTION,HORA_LAST_CONECTION FROM users.users_table;";

            show.ShowDataGridFound(findinggrid, orden);
            encontradoslabel.Text = show.getcuenta().ToString();
        }
        private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try {
                dataout = new string[5];
                LoginClass ver  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string     dato = this.dataGrid.CurrentCell.Value.ToString();

                string orden = "SELECT * FROM " + UserAccessForm.getusername() + "_contacts_table WHERE NOMBRE='" + dato + "';";
                if (ver.fillcombos(namecombo, telefonocombo, orden))
                {
                    editbutton.Enabled   = true;
                    quitarbutton.Enabled = true;
                    dataout[0]           = namecombo.Text;
                    dataout[1]           = telefonocombo.Text;
                    dataout[2]           = LoginClass.getdata()[0];
                    dataout[3]           = LoginClass.getdata()[1];
                    dataout[4]           = LoginClass.getdata()[2];
                }
                else
                {
                    editbutton.Enabled   = false;
                    quitarbutton.Enabled = false;
                }
            } catch (NullReferenceException pafh) { pafh.ToString(); }
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            TimeClass timeobject = new TimeClass();

            hourlabelstrip.Text = timeobject.clockshape();
            datelabelstrip.Text = timeobject.dateshape();


            AgendaClass ev = new AgendaClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            string hora       = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
            string fechal     = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString();;
            string fechashort = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString();



            string orden = "SELECT DESCRIPCION, HORA, PRIORIDAD FROM " + UserAccessForm.getusername() + "_events_table WHERE (HORA='" + hora + "' AND ( FECHA='" + fechal + "' or `FECHA DE RECORDATORIO`='" + fechashort + "'))AND ACTIVO='SI';";

            if (ev.getnametarea(orden))
            {
                DireccionGestor.setsombrestatic(ev.getname());
                DireccionGestor.setotrostatic(ev.gettime());
                DireccionGestor.setprioridadstatic(ev.getprioridad());
                DireccionGestor.setestadostatic(true);

                SystemSounds.Hand.Play();
                MessageBox.Show("SON LAS " + ev.gettime() + " ES HORA DE " + ev.getname());
            }
            cuenta++;
            if (cuenta == 5000)
            {
                cuenta = 0;
                backbuttonstrip.PerformClick();
            }
        }
        private void quitarbutton_Click(object sender, EventArgs e)
        {
            LoginClass ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());

            string orden = "DELETE FROM " + UserAccessForm.getusername() + "_contacts_table WHERE ID='" + dataout[4] + "';";

            ver.ordensql(orden);
            editbutton.Enabled   = false;
            quitarbutton.Enabled = false;
            orden = "SELECT NOMBRE,TELEFONO,DIRECCION,EMAIL FROM " + UserAccessForm.getusername() + "_contacts_table;";
            ver.ShowDataGridFound(dataGrid, orden);
            cuentalabel.Text   = ver.getcuenta().ToString();
            namecombo.Text     = "";
            telefonocombo.Text = "";
            MessageBox.Show("CONTACTO ELIMINADO");
        }
        private void outbutton_Click(object sender, EventArgs e)
        {
            string mensaje;
            string accion;
            string salida;

            if (actionbox.Text == "DESPEDIR")
            {
                accion  = "NO";
                salida  = salidapicker.Value.Day.ToString() + "/" + salidapicker.Value.Month.ToString() + "/" + salidapicker.Value.Year.ToString();
                mensaje = "EMPLEADO DESPEDIDO";
            }
            else
            {
                accion  = "SI";
                salida  = "00/00/0000";
                mensaje = "EMPLEADO CONTRATADO";
            }


            EmployeeClass show         = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
            string        userDataName = UserAccessForm.getusername() + "_employee_table";
            string        mandosql     = "update " + userDataName + " set TRABAJANDO ='" + accion + "', `FECHA DE SALIDA`='" + salida + "' where `NOMBRE COMPLETO` ='" + namelabel.Text + "' and EDAD = '" + agelabel.Text + "' and PUESTO = '" + joblabel.Text + "';";

            if (show.ordensql(mandosql) == true)
            {
                MessageBox.Show("Empleado ha sido despedido");
            }
            else
            {
                MessageBox.Show(mensaje);
            }

            EmployeeFormSearch menu = new EmployeeFormSearch();

            menu.WindowState = FormWindowState.Maximized;
            menu.Show();
            this.Close();
        }
Exemple #30
0
        private void userPasswordForm_Load(object sender, EventArgs e)
        {
            try {
                picturetext.Hide();
                OKbutton.BackColor     = Color.Green;
                cancelbutton.BackColor = Color.Red;
                userlabel.Text         = UsersShowForm.getdatum()[0];
                tipolabel.Text         = UsersShowForm.getdatum()[1];
                LoginClass show  = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport());
                string     orden = "select * from  USERS_TABLE where USER_NAME = '" + userlabel.Text + "';";
                show.fillpic(picturetext, orden);


                if (picturetext.Text != "")
                {
                    string path        = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    string combinacion = System.IO.Path.Combine(path, "users");
                    string fotopath    = System.IO.Path.Combine(combinacion, picturetext.Text);
                    pictureBox.ImageLocation = fotopath;
                }

                if (UsersShowForm.getstate() == "change")
                {
                    seguridadlabel.Text = "CAMBIAR CONTRASEÑA";
                }
                else
                {
                    seguridadlabel.Text = "CONTROL DE SEGURIDAD";
                    newlabel.Hide();
                    newpasstextbox.Hide();
                }
            }
            catch (ArgumentNullException pap) {
                pap.ToString();
                MessageBox.Show("TIENE QUE SELECCIONAR UN USUARIO PARA EJECUTAR LAS FUNCIONES DEL MENU");
            }
            catch (NullReferenceException pap)
            {
                pap.ToString();
                MessageBox.Show("TIENE QUE SELECCIONAR UN USUARIO PARA EJECUTAR LAS FUNCIONES DEL MENU");
            }
        }