예제 #1
0
        private void RefreshHostSetting(HostType host)
        {
            if (chosenHost == HostType.TYPE_UNKNOWN)
            {
                return;
            }
            string accTypeName = AccountTypeDB.FromTypeCodeToString(host);
            listNameOrder = dbController.GetAllNameOrder();
            hostNameOrder = dbController.GetHostNameOrder(accTypeName);
            listEmailType = dbController.GetAllEmailTypeByAccountTypeName(accTypeName);
            listFaxType = dbController.GetAllFaxTypeByAccountTypeName(accTypeName);

            RefreshListNameOrder();
            RefreshListEmailType();
            RefreshListFaxType();
        }
예제 #2
0
 public int SetPreferredHostNameOrder(HostNameOrderDB hostOrderName)
 {
     //open connection
     if (this.OpenConnection() == true)
     {
         SQLiteTransaction trans = connection.BeginTransaction();
         int res = -1;
         try
         {
             SQLiteCommand comm = connection.CreateCommand();
             comm.Transaction = trans;
             comm.CommandText = "UPDATE host_contact_name_order SET contact_name_order_id = @name_order_id where account_type_id=@account_type_id";
             comm.Parameters.AddWithValue("@name_order_id", hostOrderName.ContactNameOrderId);
             comm.Parameters.AddWithValue("@account_type_id", hostOrderName.AccountTypeId);
             comm.ExecuteNonQuery();
             trans.Commit();
             res = 1;
         }
         catch (Exception ex)
         {
             trans.Rollback();
         }
         this.CloseConnection();
         return res;
     }
     return 0;
 }
예제 #3
0
        public HostNameOrderDB GetHostNameOrder(string accountTypeString)
        {
            string query = "SELECT host_contact_name_order.id as id, account_type_id, contact_name_order_id " +
                "from account_type, host_contact_name_order where account_type.id = account_type_id and account_type.name = @name";

            //Create a list to store the result
            HostNameOrderDB hostNameOrder = new HostNameOrderDB();

            //Open connection
            if (this.OpenConnection() == true)
            {
                //Create Command
                SQLiteCommand cmd = new SQLiteCommand(query, connection);
                cmd.Parameters.AddWithValue("@name", accountTypeString);
                //Create a data reader and Execute the command
                SQLiteDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int id = Int32.Parse(dataReader["id"].ToString());
                    int account_type_id = Int32.Parse(dataReader["account_type_id"].ToString());
                    int contact_name_order_id = Int32.Parse(dataReader["contact_name_order_id"].ToString());
                    hostNameOrder.Id = id;
                    hostNameOrder.AccountTypeId = account_type_id;
                    hostNameOrder.ContactNameOrderId = contact_name_order_id;
                    break;
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

            }
            return hostNameOrder;
        }
예제 #4
0
        // name order

        public HostNameOrderDB GetPreferredHostNameOrderByAccountTypeName(string accTypeName)
        {
            HostNameOrderDB order = new HostNameOrderDB();
            if (this.OpenConnection() == true)
            {
                string query = "SELECT host_contact_name_order.id as id, host_contact_name_order.account_type_id, contact_name_order_id, name_order " +
                "FROM contact_name_order, account_type, host_contact_name_order " +
                "where host_contact_name_order.account_type_id = account_type.id and contact_name_order_id = contact_name_order.id " +
                "and account_type.name = @hostName";

                //Create Command
                SQLiteCommand cmd = new SQLiteCommand(query, connection);
                cmd.Parameters.AddWithValue("@hostName", accTypeName);
                //Create a data reader and Execute the command
                SQLiteDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int id = Int32.Parse(dataReader["id"].ToString());
                    int account_type_id = Int32.Parse(dataReader["account_type_id"].ToString());
                    int contact_name_order_id = Int32.Parse(dataReader["contact_name_order_id"].ToString());
                    string name_order = dataReader["name_order"].ToString();
                    order.Id = id;
                    order.ContactNameOrderId = contact_name_order_id;
                    order.AccountTypeId = account_type_id;
                    order.ContactNameOrderName = name_order;

                    break;
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

            }
            return order;
        }
예제 #5
0
 public int SetPreferredHostNameOrder(HostNameOrderDB hostOrderName)
 {
     DBManager db = new DBManager();
     return db.SetPreferredHostNameOrder(hostOrderName);
 }