예제 #1
0
        private void btn_create_Click(object sender, EventArgs e)
        {
            try
            {
                MdiParent parent = (MdiParent)this.MdiParent;


                if (txt_Identification.Text != "" && txt_FirstName.Text != "" && txt_LastName.Text != "" && txt_Neighborhood.Text != "" &&
                    txt_Adress.Text != "" && cmb_UserType.Text != "" && txt_User.Text != "" && txt_Password.Text != "")
                {
                    identification = txt_Identification.Text;
                    string   fName    = txt_FirstName.Text;
                    string   lName    = txt_LastName.Text;
                    DateTime date     = Convert.ToDateTime(dtp_Birthdate.Value.Date);
                    string   adNeigh  = txt_Neighborhood.Text;
                    string   adNum    = txt_Adress.Text;
                    int      typeUser = Convert.ToInt32(cmb_UserType.SelectedValue.ToString());
                    string   user     = txt_User.Text;
                    string   password = txt_Password.Text;

                    password = parent.Encrypt(password);

                    DialogResult result = MessageBox.Show("¿Desea Agregar el Cliente?", "Agregar Usuario", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        uta = new MercaFacil_2DataSetTableAdapters.UsuarioTableAdapter();

                        uta.Insert(fName, lName, identification, user, password, typeUser, adNeigh, adNum, date, System.DateTime.Now, 0);

                        parent.logTA.Insert("Creación de usuario", "Se ha creado un usuario", System.DateTime.Now, parent.CurrentUser.Id);


                        btn_Add_Telephone.Visible = true;
                    }
                }
                else
                {
                    MessageBox.Show("Llene Correctamente los Datos...", "¡Atención!", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Ha Ocurrido el Siguiente Error: " + error, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void btn_Enter_Click(object sender, EventArgs e)
        {
            MercaFacil_2DataSetTableAdapters.UsuarioTableAdapter uta;
            uta = new MercaFacil_2DataSetTableAdapters.UsuarioTableAdapter();

            MercaFacil_2DataSet.UsuarioDataTable answer;

            try
            {
                string user     = txt_User.Text;
                string password = txt_Password.Text;

                MdiParent parent = (MdiParent)this.MdiParent;

                password = parent.Encrypt(password);

                answer = uta.Login(user, password);

                if (answer.Count > 0)
                {
                    parent.CurrentUser = answer[0];

                    parent.lbl_NameUser.Text    = "BIENVENIDO: " + parent.CurrentUser.Nombres.ToString();
                    parent.lbl_NameUser.Visible = true;
                    parent.showUser(parent.CurrentUser.Tipo_Usuario);
                    parent.logTA.Insert("Inicio de sesión", "usuario: " + answer[0].Nombres, System.DateTime.Now, answer[0].Id);

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Acceso Denegado! Usuario no Encontrado... Intentelo de nuevo", "¡Atención!",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Stop);

                    txt_User.Clear();
                    txt_Password.Clear();
                }

                parent.btn_Login.Visible  = false;
                parent.btn_Logout.Visible = true;
            }catch (Exception error)
            {
                MessageBox.Show(" " + error);
            }
        }