예제 #1
0
파일: frmMenu.cs 프로젝트: Leandro82/Agenda
        private void alterarExcluirEventoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int    i       = 0;
            int    cont    = cs.Usuario().Rows.Count - 1;
            string usuario = toolStripLabel2.Text;

            frmLogin frm = new frmLogin();

            if (Application.OpenForms.OfType <frmLogin>().Count() > 0)
            {
                Application.OpenForms[frm.Name].Close();
            }

            if (toolStripLabel2.Text == null)
            {
                var log = new frmLogin();

                if (Application.OpenForms.OfType <frmLogin>().Count() > 0)
                {
                    Application.OpenForms[log.Name].Focus();
                }
                else
                {
                    log.Show();
                }
            }
            else
            {
                string rec2 = toolStripLabel2.Text;

                while (i <= cont)
                {
                    if (cs.Usuario().Rows[i]["nome"].ToString() == usuario)
                    {
                        aux2 = i;
                    }
                    i = i + 1;
                }

                if (cs.Usuario().Rows[aux2]["privilegio"].ToString() == "Ok")
                {
                    priv2 = "Ok";
                }
                else
                {
                    priv2 = "";
                }

                var peq = new frmPesqEdEventos(rec2, priv2);
                if (Application.OpenForms.OfType <frmPesqEdEventos>().Count() > 0)
                {
                    Application.OpenForms[peq.Name].Focus();
                }
                else
                {
                    peq.Show();
                }
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int i   = 0;
            int aux = 0;

            cont = co.Usuario().Rows.Count - 1;;


            while (i <= cont)
            {
                if (co.Usuario().Rows[i]["nome"].ToString() == textBox1.Text)
                {
                    aux = 1;
                }
                i = i + 1;
            }

            if (aux == 1)
            {
                Fechar();
                MessageBox.Show("Usuário já cadastrado");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                label5.Text   = "";
            }
            else
            {
                us.Nome   = textBox1.Text;
                us.Login  = textBox2.Text;
                us.Senha  = textBox4.Text;
                us.Acesso = "";

                if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
                {
                    Fechar();
                    MessageBox.Show("Preencha todos os campos");
                }
                else
                {
                    ca.cadastro(us);
                    Fechar();
                    MessageBox.Show("Usuário cadastrado");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                    textBox4.Text = "";
                    label5.Text   = "";
                }
            }
        }
예제 #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            int    i    = 0;
            string aux  = "aux";
            int    rec1 = 100000;
            int    rec2 = 100001;

            int cont = co.Usuario().Rows.Count;

            while (i < cont && rec1 != rec2)
            {
                if (textBox1.Text == co.Usuario().Rows[i]["login"].ToString())
                {
                    rec1 = i;
                }


                if (textBox2.Text == co.Usuario().Rows[i]["senha"].ToString())
                {
                    rec2 = i;
                }

                i = i + 1;
            }

            if (rec1 == 100000)
            {
                Fechar();
                MessageBox.Show("Usuário não cadastrado");
                textBox1.Focus();
            }
            else
            {
                if (rec1 != rec2)
                {
                    Fechar();
                    MessageBox.Show("Usuário ou senha inválido");
                    textBox1.Clear();
                    textBox2.Clear();
                    textBox1.Focus();
                }
                else if (co.Usuario().Rows[rec1]["acesso"].ToString() == "")
                {
                    Form2 f2 = new Form2();
                    AuxClas.login   = co.Usuario().Rows[rec1]["login"].ToString();
                    AuxClas.usuario = co.Usuario().Rows[rec1]["nome"].ToString();

                    if (co.Usuario().Rows[rec1]["privilegio"].ToString() == "Ok")
                    {
                        AuxClas.privilegio = "Ok";
                    }
                    else
                    {
                        AuxClas.privilegio = "";
                    }
                    f2.Show();
                    f2.Atualizar();
                    this.Hide();
                }
                else
                {
                    AuxClas.usuario = co.Usuario().Rows[rec1]["nome"].ToString();
                    if (co.Usuario().Rows[rec1]["privilegio"].ToString() == "Ok")
                    {
                        AuxClas.privilegio = "Ok";
                    }

                    else
                    {
                        AuxClas.privilegio = "";
                    }
                    AuxClas.auxiliar = aux;


                    mn.Show();
                    mn.Atualizar();


                    this.Hide();
                }
            }
        }
예제 #4
0
        private void Principal_Load(object sender, EventArgs e)
        {
            int     i     = 0;
            int     data  = 0;
            int     cont  = co.Evento().Rows.Count - 1;
            int     cont1 = cs.Usuario().Rows.Count - 1;
            Version appVersion;

            d = co.Evento().Rows.Count - 2;
            Data();
            Copias();
            timer2.Enabled = true;
            timer2.Start();
            seg = 180;

            Atualizar();

            toolStripLabel5.Text = DateTime.Now.ToShortDateString();

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                appVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
            }
            else
            {
                appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            }

            toolStripLabel7.Text = Convert.ToString(appVersion);

            if (nt == "Ok")
            {
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(10000, "Atenção", "Agenda Etec já está em uso, para restaurar clique duas vezes sobre o ícone", ToolTipIcon.Info);
            }


            if (aux1 == "aux")
            {
            }
            else
            {
                while (i <= cont)
                {
                    if (Convert.ToDateTime(co.BuscaDataServidor()).ToString("dd/MM/yyyy") == Convert.ToDateTime(co.Evento().Rows[i]["data"].ToString()).ToString("dd/MM/yyyy"))
                    {
                        data = data + 1;
                    }
                    i = i + 1;
                }

                if (nt == "Ok")
                {
                }
                else
                {
                    if (data >= 1)
                    {
                        string            message = "Temos " + data + " eventos hoje, deseja ver?";
                        string            caption = "Aviso";
                        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                        DialogResult      result;

                        result = MessageBox.Show(message, caption, buttons);

                        if (result == System.Windows.Forms.DialogResult.No)
                        {
                        }
                        else
                        {
                            var peq = new frmPesqEventos(co.BuscaDataServidor(), visualizar);
                            if (Application.OpenForms.OfType <frmPesqEventos>().Count() > 0)
                            {
                                Application.OpenForms[peq.Name].Focus();
                            }
                            else
                            {
                                peq.Show();
                                peq.TopMost = true;
                            }
                        }
                    }
                }
            }
        }