Esempio n. 1
0
        /// <summary>
        /// Get list user with department and position
        /// </summary>
        /// <param name="dept_code"></param>
        /// <param name="postion_code"></param>
        public void GetListUser(string dept_code, string postion_code)
        {
            //SQL library
            PSQL   SQL   = new PSQL();
            string query = string.Empty;

            //Open SQL connection
            SQL.Open();
            //SQL query string
            query = @"SELECT user_cd, user_name, locale_id, multi_login_flag, registration_user_cd, registration_date_time,
                      registrated_factory_cd, dept_cd, user_position_cd FROM m_mes_user WHERE 1=1 ";
            if (!string.IsNullOrEmpty(dept_code))
            {
                query += "and dept_cd ='" + dept_code + "' ";
            }
            if (!string.IsNullOrEmpty(postion_code))
            {
                query += "and user_position_cd ='" + postion_code + "' ";
            }
            query += "ORDER BY user_cd";
            //Execute reader for read database
            IDataReader reader = SQL.Command(query).ExecuteReader();

            query = string.Empty;
            while (reader.Read())
            {
                //Get an item
                m_mes_user outItem = new m_mes_user
                {
                    user_cd                = reader["user_cd"].ToString(),
                    user_name              = reader["user_name"].ToString(),
                    locale_id              = (int)reader["locale_id"],
                    multi_login_flag       = reader["multi_login_flag"].ToString(),
                    registration_date_time = (DateTime)reader["registration_date_time"],
                    registration_user_cd   = reader["registration_user_cd"].ToString(),
                    dept_cd                = reader["dept_cd"].ToString(),
                    user_position_cd       = reader["user_position_cd"].ToString(),
                };
                listMesUser.Add(outItem);
            }
            reader.Close();
            //Close SQL connection
            SQL.Close();
        }
Esempio n. 2
0
 private void LoginEvent2()
 {
     try
     {
         if (!string.IsNullOrEmpty(txtUsername.Text))
         {
             loginpass = loginpass.CheckLogIn(txtUsername.Text, txtpass.Text);
             if (loginpass.is_online)
             {
                 if (MessageBox.Show("This user is online." + Environment.NewLine + "Are you want re-login?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                 {
                     return;
                 }
             }
             loginpass.LogIO(txtUsername.Text, true);
             mesuser            = mesuser.GetUser(loginpass.user_cd);
             UserData.dept      = mesuser.dept_cd;
             UserData.usercode  = mesuser.user_cd;
             UserData.username  = mesuser.user_name;
             UserData.logintime = loginpass.last_login_time;
             //  UserData.role_permision = userrole.GetListRole(loginpass.user_cd);
             //Show main form
             Warehouse wh = new Warehouse();
             this.Hide();
             txtpass.Clear();
             wh.ShowDialog();
             loginpass.LogIO(txtUsername.Text, false);
             this.Show();
             this.Focus();
         }
         else
         {
             MessageBox.Show("Please fill user code!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             txtUsername.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }