Esempio n. 1
0
        private void btnEntrarLogin_Click_1(object sender, EventArgs e)
        {
            String pass   = txtPassword.Text;
            String user   = txtUsername.Text;
            int    result = serviceDA.ConfirmUsuario(user, pass);

            if (cont < 4)
            {
                if (result != 0)
                {
                    AlmacenDisecWS.employee emp = serviceDA.EmployeeByCode(user);
                    // mainWindow.Closed += (s, args) => this.Close();
                    this.Hide();
                    frmPrincipal mainWindow = new frmPrincipal();
                    mainWindow.lblCargo.Text     = emp.privilege.ToString();
                    mainWindow.lblNombre.Text    = emp.employee_name;
                    mainWindow.lblApellidos.Text = emp.last_name + " " + emp.second_last_name;
                    if (emp.privilege.ToString() == "STOREKEEPER")
                    {
                        mainWindow.btnReport.Enabled = false;
                        mainWindow.btnGUser.Enabled  = false;
                    }
                    else if (emp.privilege.ToString() == "TECHNICIAN")
                    {
                        mainWindow.btnReport.Enabled   = false;
                        mainWindow.btnGUser.Enabled    = false;
                        mainWindow.btnSupplier.Enabled = false;
                        mainWindow.btnStore.Enabled    = false;
                        mainWindow.btnCategory.Enabled = false;
                        mainWindow.btnFamiliy.Enabled  = false;
                        mainWindow.btnBrand.Enabled    = false;
                        mainWindow.btnMaterial.Enabled = false;
                        mainWindow.btnTool.Enabled     = false;
                    }


                    mainWindow.Show();

                    return;
                }
                else
                {
                    frmMessageBoxDontCoincidence fm = new frmMessageBoxDontCoincidence();
                    fm.ShowDialog();
                    cont++;
                }
            }
            else
            {
                frmMessageBoxBlockSystem fm = new frmMessageBoxBlockSystem();
                fm.ShowDialog();
                cont = 0;
                btnEntrarLogin.Enabled = false;
                tmLogin.Start();
            }
        }
        private void BtnModify_Click(object sender, EventArgs e)
        {
            frmUser frm = new frmUser();

            frm.flag = false;

            AddOwnedForm(frm);
            frm.FormBorderStyle = FormBorderStyle.None;
            frm.TopLevel        = false;
            frm.Dock            = DockStyle.Fill;
            this.Controls.Add(frm);
            this.Tag = frm;
            frm.cboPrivilege.Enabled = false;

            String cod = dgvSearch.CurrentRow.Cells[0].Value.ToString();

            AlmacenDisecWS.employee emp = new AlmacenDisecWS.employee();
            emp = serviceDA.EmployeeByCode(cod);

            frm.lblId.Text          = emp.employee_id.ToString();
            frm.txtCode.Text        = emp.eployee_code;
            frm.txtName.Text        = emp.employee_name;
            frm.txtLastName1.Text   = emp.last_name;
            frm.txtLastName2.Text   = emp.second_last_name;
            frm.txtEmail.Text       = emp.email_employee;
            frm.txtDNI.Text         = emp.dni;
            frm.txtPassword.Enabled = false;
            frm.txtSalary.Text      = emp.salary.ToString();
            frm.cboPrivilege.Text   = dgvSearch.CurrentRow.Cells[8].Value.ToString();
            frm.btnDelete.Enabled   = true;
            if (emp.gender == "F")
            {
                frm.rbWoman.Checked = true;
            }
            else
            {
                frm.rbMan.Checked = true;
            }


            frm.BringToFront();
            frm.Show();
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (flag == true)
            {
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtLastName1.Text) || String.IsNullOrEmpty(txtLastName2.Text) ||
                    String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtDNI.Text) || String.IsNullOrEmpty(txtSalary.Text) || String.IsNullOrEmpty(txtPassword.Text) ||
                    cboPrivilege.SelectedIndex == -1 || (rbWoman.Checked == false && rbMan.Checked == false))
                {
                    frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
                    frm.ShowDialog();
                }
                else
                {
                    AlmacenDisecWS.employee emp = new AlmacenDisecWS.employee();

                    frmMessageBoxSave frm = new frmMessageBoxSave();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        string name   = txtName.Text;
                        string apP    = txtLastName1.Text;
                        string apM    = txtLastName2.Text;
                        string DNI    = txtDNI.Text;
                        string email  = txtEmail.Text;
                        string pass   = txtPassword.Text;
                        Double sueldo = Double.Parse(txtSalary.Text);

                        emp.employee_name    = name;
                        emp.last_name        = apP;
                        emp.second_last_name = apM;
                        emp.dni            = DNI;
                        emp.email_employee = email;
                        emp.salary         = sueldo;
                        emp.password       = pass;
                        int a = 0;

                        if (cboPrivilege.SelectedValue.ToString() == "MANAGER")
                        {
                            a = 1;
                        }
                        else if (cboPrivilege.SelectedValue.ToString() == "STOREKEEPER")
                        {
                            a = 2;
                        }
                        else
                        {
                            a = 3;
                        }

                        if (rbMan.Checked == true)
                        {
                            emp.gender = "M";
                        }
                        else
                        {
                            emp.gender = "F";
                        }
                        int result = serviceDA.insertEmployee(emp, a);
                    }
                    frmSearchUser fm = Owner as frmSearchUser;
                    fm.dgvSearch.AutoGenerateColumns = false;
                    fm.dgvSearch.DataSource          = serviceDA.queryAllEmployee();

                    this.Close();
                }
            }
            else
            {
                if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtLastName1.Text) || String.IsNullOrEmpty(txtLastName2.Text) ||
                    String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtDNI.Text) || String.IsNullOrEmpty(txtSalary.Text) ||
                    (rbWoman.Checked == false && rbMan.Checked == false))
                {
                    frmMessageBoxFillNull frm = new frmMessageBoxFillNull();
                    frm.ShowDialog();
                }
                else
                {
                    AlmacenDisecWS.employee emp = new AlmacenDisecWS.employee();

                    frmMessageBoxSave frm = new frmMessageBoxSave();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        string name  = txtName.Text;
                        string apP   = txtLastName1.Text;
                        string apM   = txtLastName2.Text;
                        string DNI   = txtDNI.Text;
                        string email = txtEmail.Text;

                        Double sueldo = Double.Parse(txtSalary.Text);
                        emp.employee_id      = Int32.Parse(lblId.Text);
                        emp.employee_name    = name;
                        emp.last_name        = apP;
                        emp.second_last_name = apM;
                        emp.dni            = DNI;
                        emp.salary         = sueldo;
                        emp.email_employee = email;
                        if (rbMan.Checked == true)
                        {
                            emp.gender = "M";
                        }
                        else
                        {
                            emp.gender = "F";
                        }
                        int result = serviceDA.updateEmployee(emp);
                    }
                }
                frmSearchUser fm = Owner as frmSearchUser;
                fm.dgvSearch.AutoGenerateColumns = false;
                fm.dgvSearch.DataSource          = serviceDA.queryAllEmployee();

                this.Close();
            }
        }