Ejemplo n.º 1
0
        // 以輸入權限ID搜尋權限資料
        public AuthorizationModel searchByAuthoID()
        {
            if (this.connectToDB())
            {
                try
                {
                    DataTable dataSet = new DataTable();

                    String       searchString  = String.Format("SELECT * FROM authorization WHERE authoID = '" + this._authoModel.GetAuthoID() + "'");
                    MySqlCommand searchCommand = new MySqlCommand(searchString, myConnection);
                    searchCommand.ExecuteNonQuery();

                    MySqlDataAdapter adapter = new MySqlDataAdapter(searchCommand);
                    adapter.Fill(dataSet);

                    foreach (DataRow searchDr in dataSet.Rows)
                    {
                        _authoModel.SetAuthoName(searchDr["authoName"].ToString());
                        _authoModel.SetAuthoValue(searchDr["authoValue"].ToString());
                    }
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Number + " : " + ex.Message);
                }
            }
            this.closeConnection();

            return(this._authoModel);
        }
Ejemplo n.º 2
0
 public void TestAuthoValue()
 {
     _autho.SetAuthoValue("testValue");
     Assert.AreEqual("testValue", _autho.GetAuthoValue());
 }
Ejemplo n.º 3
0
 // 建構子
 public AuthorizationController(AuthorizationPresentationModel authoPresentationModel)
 {
     _authoModel.SetAuthoID(authoPresentationModel.GetAuthoID());
     _authoModel.SetAuthoName(authoPresentationModel.GetAuthoName());
     _authoModel.SetAuthoValue(authoPresentationModel.GetAuthoValue());
 }