예제 #1
0
        public UserController(MaintainUsersForm child, int usrID, int profilePictureID)
        {
            userID    = usrID;
            _user     = new MUser(userID);
            picID     = profilePictureID;
            _userForm = child;

            if (userID == 1)
            {
                _user.giveAdmin();
                _user.SetHQ(MFranchise.isFranchisor());
            }

            String[] loc = _user.GetLocation();
            if (loc[0] != "0")
            {
                _userForm.InitializeCombos(loc[0], loc[1], loc[2]);
            }
            else
            {
                String[] op = MFranchise.GetOpReg();
                _userForm.InitializeCombos(op[2], op[3], op[4]);
            }

            LoadUserPic();
            _userForm.SetButtons(_user.IsAdmin(), _user.IsHQ());
            _userForm.SetFields(_user.Get());

            /*try { _userForm.SetFields(_user.Get()); }
             * catch (Exception) { MessageBox.Show("Failed to load User"); _userForm.Close(); }*/
        }
예제 #2
0
파일: MUser.cs 프로젝트: pkurowsk/NI-FAFOS
        public MUser(int Userid)
        {
            userID = Userid;

            try
            {
                _values = GetRow(userID.ToString(), "[User]", "user_id");
                if (String.Equals(Regex.Replace(_values[15], @"\s", ""), "true", StringComparison.OrdinalIgnoreCase))
                {
                    isAdmin = true;
                }
                if (String.Equals(Regex.Replace(_values[15], @"\s", ""), "false", StringComparison.OrdinalIgnoreCase))
                {
                    isAdmin = false;
                }

                SetHQ(_values[14]);
                perOwnership = Convert.ToSingle(_values[16]);
            }
            catch (Exception)
            {
                _values = new string[22];
                String[] op = MFranchise.GetOpReg();
                _values[19] = op[2];
                _values[17] = op[3];
                _values[18] = op[4];
                String        connString = Properties.Settings.Default.FAFOS;
                DataTable     dt         = new DataTable();
                SqlConnection con        = new SqlConnection(connString);

                con.Open();
                SqlCommand command = new SqlCommand("INSERT INTO [User] VALUES (" + userID + ",'<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','<empty>','False','False',0," + _values[17] + "," + _values[18] + "," + _values[19] + "," + Properties.Settings.Default.FranchiseeID + ",0)", con);
                command.ExecuteNonQuery();
                con.Close();
            }
        }