Ejemplo n.º 1
0
        private void btnEmployee_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("Check_User", parentForm.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@empLoginID", SqlDbType.NVarChar).Value = parentForm.employeeID.ToUpper().ToString();
            SqlParameter UserName_Param = cmd.Parameters.Add("@empFirstName", SqlDbType.NVarChar, 50);

            UserName_Param.Direction = ParameterDirection.Output;

            parentForm.conn.Open();
            cmd.ExecuteNonQuery();
            parentForm.conn.Close();

            if (cmd.Parameters["@empFirstName"].Value == DBNull.Value)
            {
                if (parentForm.employeeID == parentForm.SystemMasterUserName)
                {
                    EmployeeMain employeeMainForm = new EmployeeMain();
                    employeeMainForm.parentForm = this.parentForm;
                    employeeMainForm.Show();
                }
                else
                {
                    MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                if (parentForm.userLevel >= parentForm.btnManagementEmployee)
                {
                    EmployeeMain employeeMainForm = new EmployeeMain();
                    employeeMainForm.parentForm = this.parentForm;
                    employeeMainForm.Show();
                }
                else
                {
                    MessageBox.Show("NOT AUTHORIZED", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }